OSDN Git Service

If a plugin or theme is already installed and the `--version` parameter is used,...
authorDaniel Bachhuber <d@danielbachhuber.com>
Sun, 7 Jul 2013 17:58:02 +0000 (18:58 +0100)
committerDaniel Bachhuber <d@danielbachhuber.com>
Sun, 7 Jul 2013 17:58:02 +0000 (18:58 +0100)
See https://github.com/wp-cli/wp-cli/pull/476#issuecomment-20354895

php/commands/plugin.php
php/commands/theme.php

index 8ebb2ed..73e11ea 100644 (file)
@@ -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 <plugin|zip> [--version=<version>] [--activate]
+        * @synopsis <plugin|zip> [--version=<version>] [--activate] [--yes]
         */
        function install( $args, $assoc_args ) {
                parent::install( $args, $assoc_args );
index e682430..df2da7f 100644 (file)
@@ -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 <theme|zip> [--version=<version>] [--activate]
+        * @synopsis <theme|zip> [--version=<version>] [--activate] [--yes]
         */
        function install( $args, $assoc_args ) {
                parent::install( $args, $assoc_args );