OSDN Git Service

Merge pull request #914 from rodrigoprimo/too-many-args
authorCristi Burcă <scribu@gmail.com>
Thu, 12 Dec 2013 23:01:48 +0000 (15:01 -0800)
committerCristi Burcă <scribu@gmail.com>
Thu, 12 Dec 2013 23:01:48 +0000 (15:01 -0800)
Stop wp-cli execution when there are too many positional arguments

features/validation.feature
php/WP_CLI/Dispatcher/Subcommand.php

index ad1f89f..a431787 100644 (file)
@@ -17,14 +17,18 @@ Feature: Argument validation
     Given an empty directory
     And WP files
 
-    When I try `wp core config invalid`
+    When I try `wp core config`
     Then the return code should be 1
     And STDERR should contain:
       """
       Parameter errors:
       """
+    And STDERR should contain:
+      """
+      missing --dbname parameter
+      """
 
-    When I try `wp core config invalid --invalid --other-invalid`
+    When I try `wp core config --invalid --other-invalid`
     Then the return code should be 1
     And STDERR should contain:
       """
@@ -34,3 +38,11 @@ Feature: Argument validation
       """
       unknown --other-invalid parameter
       """
+
+    When I try `wp core version invalid`
+    Then the return code should be 1
+    And STDERR should contain:
+      """
+      Error: Too many positional arguments: invalid
+      """
+    And STDOUT should be empty
index 0e4685a..89402b7 100644 (file)
@@ -171,7 +171,7 @@ class Subcommand extends CompositeCommand {
 
                $unknown_positionals = $validator->unknown_positionals( $args );
                if ( !empty( $unknown_positionals ) ) {
-                       \WP_CLI::warning( 'Too many positional arguments: ' .
+                       \WP_CLI::error( 'Too many positional arguments: ' .
                                implode( ' ', $unknown_positionals ) );
                }