From: Daniel Bachhuber Date: Sun, 7 Jul 2013 17:58:02 +0000 (+0100) Subject: If a plugin or theme is already installed and the `--version` parameter is used,... X-Git-Tag: v0.11.0~42^2~8 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b07154ed976b937aa9875cf55573722e38308ef6;p=wvm%2Fwvm.git If a plugin or theme is already installed and the `--version` parameter is used, prompt the user to confirm they'd like it installed. See https://github.com/wp-cli/wp-cli/pull/476#issuecomment-20354895 --- diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 8ebb2ed7..73e11eac 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -173,7 +173,10 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade { case 'newer_installed': case 'update_available': if ( isset( $assoc_args['version'] ) - && version_compare( $status['version'], $assoc_args['version'], '>=' ) ) { + && version_compare( $status['version'], $assoc_args['version'], '!=' ) ) { + + WP_CLI::confirm( "A different version is installed. Overwrite it?", $assoc_args ); + list( $file, $name ) = $this->parse_name( array( $api->slug ) ); $this->_delete( $file ); } @@ -249,7 +252,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade { /** * Install a plugin. * - * @synopsis [--version=] [--activate] + * @synopsis [--version=] [--activate] [--yes] */ function install( $args, $assoc_args ) { parent::install( $args, $assoc_args ); diff --git a/php/commands/theme.php b/php/commands/theme.php index e6824309..df2da7f6 100644 --- a/php/commands/theme.php +++ b/php/commands/theme.php @@ -121,6 +121,8 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade { } else if ( $theme_obj->exists() && version_compare( $assoc_args['version'], $theme_obj->version, '!=' ) ) { // Theme is installed, but we want a different version + WP_CLI::confirm( "A different version is installed. Overwrite it?", $assoc_args ); + WP_CLI::log( sprintf( 'Installing %s (%s)', $api->name, $api->version ) ); delete_theme( $theme_obj->stylesheet ); $result = WP_CLI\Utils\get_upgrader( $this->upgrader )->install( $api->download_link ); @@ -157,7 +159,7 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade { /** * Install a theme. * - * @synopsis [--version=] [--activate] + * @synopsis [--version=] [--activate] [--yes] */ function install( $args, $assoc_args ) { parent::install( $args, $assoc_args );