OSDN Git Service

show version default, remove color from version and align left
authortolgap <tolga@hoppinger.com>
Mon, 29 Apr 2013 23:05:19 +0000 (01:05 +0200)
committertolgap <tolga@hoppinger.com>
Mon, 29 Apr 2013 23:05:19 +0000 (01:05 +0200)
man-src/plugin-status.txt
man/plugin-status.1
php/WP_CLI/CommandWithUpgrade.php
php/commands/plugin.php

index 3313520..6902ac2 100644 (file)
@@ -2,8 +2,4 @@
 
 * `<plugin>`:
 
-       A particular plugin to show the status for.
-
-* `--with-version`:
-
-  If set, the plugin version will also be shown.
\ No newline at end of file
+       A particular plugin to show the status for.
\ No newline at end of file
index 126cac0..797ffa3 100644 (file)
@@ -7,7 +7,7 @@
 \fBwp\-plugin\-status\fR \- See the status of one or all plugins\.
 .
 .SH "SYNOPSIS"
-wp plugin status [\fIplugin\fR] [\-\-with\-version]
+wp plugin status [\fIplugin\fR]
 .
 .SH "OPTIONS"
 .
@@ -16,10 +16,4 @@ wp plugin status [\fIplugin\fR] [\-\-with\-version]
 .
 .IP
 A particular plugin to show the status for\.
-.
-.TP
-\fB\-\-with\-version\fR:
-.
-.IP
-If set, the plugin version will also be shown\.
 
index f7ba9e5..a994eb2 100644 (file)
@@ -20,23 +20,18 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
 
        abstract protected function install_from_repo( $slug, $assoc_args );
 
-       function status( $args, $assoc_args ) {
+       function status( $args ) {
                // Force WordPress to check for updates
                call_user_func( $this->upgrade_refresh );
 
                if ( empty( $args ) ) {
-                       $with_version = false;
-                       if( in_array( 'with-version', $assoc_args ) ) {
-                               $with_version = true;
-                       }
-
-                       $this->status_all( $with_version );
+                       $this->status_all();
                } else {
                        $this->status_single( $args );
                }
        }
 
-       private function status_all( $with_version = false ) {
+       private function status_all() {
                $items = $this->get_all_items();
 
                $n = count( $items );
@@ -44,18 +39,17 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
                // Not interested in the translation, just the number logic
                \WP_CLI::line( sprintf( _n( "%d installed {$this->item_type}:", "%d installed {$this->item_type}s:", $n ), $n ) );
 
+               $padding = $this->get_padding($items);
+
                foreach ( $items as $file => $details ) {
                        if ( $details['update'] ) {
                                $line = ' %yU%n';
                        } else {
                                $line = '  ';
                        }
-
                        $line .= $this->format_status( $details['status'], 'short' );
-                       $line .= " " . $details['name'];
-                       if ( $with_version ) {
-                               $line .= " " . $this->format_version( $details['version'] ) . "%n";
-                       }
+                       $line .= " " . str_pad( $details['name'], $padding );
+                       $line .= "%n " . $this->format_version( $details['version'] ) . "%n";
 
                        \WP_CLI::line( $line );
                }
@@ -65,6 +59,20 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
                $this->show_legend( $items );
        }
 
+       private function get_padding( $items ) {
+               $max_len = 0;
+
+               foreach ( $items as $details ) {
+           $len = strlen( $details['name'] );
+
+           if ( $len > $max_len ) {
+        $max_len = $len;
+           }
+               }
+
+               return $max_len;
+       }
+
        private function show_legend( $items ) {
                $statuses = array_unique( wp_list_pluck( $items, 'status' ) );
 
@@ -192,7 +200,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
        }
 
        protected function format_version( $version ) {
-               return '%c' . $version;
+               return '' . $version;
        }
 
        private function get_color( $status ) {
index 4c01e3d..f761afb 100644 (file)
@@ -22,10 +22,10 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
        /**
         * See the status of one or all plugins.
         *
-        * @synopsis [<plugin>] [--with-version]
+        * @synopsis [<plugin>]
         */
-       function status( $args, $assoc_args ) {
-               parent::status( $args, $assoc_args );
+       function status( $args ) {
+               parent::status( $args );
        }
 
        protected function status_single( $args ) {