OSDN Git Service

add support for PsySH in `wp shell`
authorscribu <mail@scribu.net>
Tue, 13 Aug 2013 23:51:15 +0000 (02:51 +0300)
committerscribu <mail@scribu.net>
Wed, 14 Aug 2013 00:06:01 +0000 (03:06 +0300)
also, replace Boris as suggested package

bin/ci/install_dependencies.sh
composer.json
php/commands/shell.php

index 6fbef59..1b2e572 100755 (executable)
@@ -9,7 +9,6 @@ curl http://behat.org/downloads/behat.phar > behat.phar
 
 # install dependencies
 composer install --no-interaction --prefer-source
-composer require d11wtq/boris=dev-master --no-interaction --prefer-source
 
 # set up WP install
 ./bin/wp core download --version=$WP_VERSION --path=/tmp/wp-cli-test-core-download-cache/
index a572e0a..0e5aa54 100644 (file)
@@ -15,7 +15,7 @@
                "rmccue/requests": "dev-master"
        },
        "suggest": {
-               "d11wtq/boris": "Enhanced `wp shell` functionality"
+               "psy/psysh": "Enhanced `wp shell` functionality"
        },
        "autoload": {
                "psr-0": { "WP_CLI": "php" }
index ef0869e..ee95860 100644 (file)
@@ -18,20 +18,27 @@ class Shell_Command extends \WP_CLI_Command {
         */
        public function __invoke( $_, $assoc_args ) {
                $implementations = array(
+                       '\\Psy\\Shell',
                        '\\Boris\\Boris',
                        '\\WP_CLI\\REPL',
                );
 
                if ( isset( $assoc_args['basic'] ) ) {
-                       unset( $implementations[0] );
+                       $class = '\\WP_CLI\\REPL';
+               } else {
+                       foreach ( $implementations as $candidate ) {
+                               if ( class_exists( $candidate ) ) {
+                                       $class = $candidate;
+                                       break;
+                               }
+                       }
                }
 
-               foreach ( $implementations as $class ) {
-                       if ( class_exists( $class ) ) {
-                               $repl = new $class( 'wp> ' );
-                               $repl->start();
-                               break;
-                       }
+               if ( '\\Psy\\Shell' == $class ) {
+                       \Psy\Shell::debug();
+               } else {
+                       $repl = new $class( 'wp> ' );
+                       $repl->start();
                }
        }
 }