OSDN Git Service

Use new public methods of `\WP_CLI\Runner` to set the `url` if it was passed as an...
authorDaniel Bachhuber <d@danielbachhuber.com>
Wed, 20 Nov 2013 22:44:05 +0000 (14:44 -0800)
committerDaniel Bachhuber <d@danielbachhuber.com>
Wed, 20 Nov 2013 22:44:05 +0000 (14:44 -0800)
php/WP_CLI/Runner.php
php/commands/core.php

index 4893ded..315a042 100644 (file)
@@ -147,7 +147,7 @@ class Runner {
                return false;
        }
 
-       private static function set_url_params( $url_parts ) {
+       public static function set_url_params( $url_parts ) {
                $f = function( $key ) use ( $url_parts ) {
                        return isset( $url_parts[ $key ] ) ? $url_parts[ $key ] : '';
                };
@@ -534,7 +534,7 @@ class Runner {
                }
        }
 
-       private static function parse_url( $url ) {
+       public static function parse_url( $url ) {
                $url_parts = parse_url( $url );
 
                if ( !isset( $url_parts['scheme'] ) ) {
index 09d15da..ab644f7 100644 (file)
@@ -444,6 +444,13 @@ class Core_Command extends WP_CLI_Command {
                        'admin_password' => ''
                ) ), EXTR_SKIP );
 
+               // Support prompting for the `--url=<url>`,
+               // which is normally a runtime argument
+               if ( isset( $assoc_args['url'] ) ) {
+                       $url_parts = \WP_CLI\Runner::parse_url( $assoc_args['url'] );
+                       \WP_CLI\Runner::set_url_params( $url_parts );
+               }
+
                $public = true;
 
                // @codingStandardsIgnoreStart