OSDN Git Service

get rid of pre_invoke() method
authorscribu <mail@scribu.net>
Sun, 9 Jun 2013 21:30:10 +0000 (00:30 +0300)
committerscribu <mail@scribu.net>
Sun, 9 Jun 2013 21:30:10 +0000 (00:30 +0300)
php/WP_CLI/Dispatcher/CompositeCommand.php
php/WP_CLI/Dispatcher/RootCommand.php
php/class-wp-cli.php

index 446bfba..42adc96 100644 (file)
@@ -68,10 +68,6 @@ class CompositeCommand {
                \WP_CLI::line( "See 'wp help $this->name <subcommand>' for more information on a specific subcommand." );
        }
 
-       function pre_invoke( &$args ) {
-               return $this->find_subcommand( $args );
-       }
-
        function find_subcommand( &$args ) {
                $name = array_shift( $args );
 
index 800ff89..0f8654e 100644 (file)
@@ -68,17 +68,6 @@ EOB
                }
        }
 
-       function pre_invoke( &$args ) {
-               $cmd_name = $args[0];
-
-               $command = $this->find_subcommand( $args );
-
-               if ( !$command )
-                       \WP_CLI::error( sprintf( "'%s' is not a registered wp command. See 'wp help'.", $cmd_name ) );
-
-               return $command;
-       }
-
        function find_subcommand( &$args ) {
                $command = array_shift( $args );
 
index cbf7f1f..06708d0 100644 (file)
@@ -247,10 +247,17 @@ class WP_CLI {
        private static function find_command_to_run( $args ) {
                $command = \WP_CLI::$root;
 
+               $cmd_path = array();
+
                while ( !empty( $args ) && $command->has_subcommands() ) {
-                       $subcommand = $command->pre_invoke( $args );
-                       if ( !$subcommand )
-                               break;
+                       $cmd_path[] = $args[0];
+
+                       $subcommand = $command->find_subcommand( $args );
+
+                       if ( !$subcommand ) {
+                               \WP_CLI::error( sprintf( "'%s' is not a registered wp command. See 'wp help'.",
+                                       implode( ' ', $cmd_path ) ) );
+                       }
 
                        $command = $subcommand;
                }