From: tolgap Date: Mon, 29 Apr 2013 23:05:19 +0000 (+0200) Subject: show version default, remove color from version and align left X-Git-Tag: v0.10.0~82^2~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c5f438b1657ff3fbbb0a2b55174ea887b6dc5a7d;p=wvm%2Fwvm.git show version default, remove color from version and align left --- diff --git a/man-src/plugin-status.txt b/man-src/plugin-status.txt index 33135209..6902ac27 100644 --- a/man-src/plugin-status.txt +++ b/man-src/plugin-status.txt @@ -2,8 +2,4 @@ * ``: - 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 diff --git a/man/plugin-status.1 b/man/plugin-status.1 index 126cac07..797ffa32 100644 --- a/man/plugin-status.1 +++ b/man/plugin-status.1 @@ -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\. diff --git a/php/WP_CLI/CommandWithUpgrade.php b/php/WP_CLI/CommandWithUpgrade.php index f7ba9e55..a994eb22 100644 --- a/php/WP_CLI/CommandWithUpgrade.php +++ b/php/WP_CLI/CommandWithUpgrade.php @@ -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 ) { diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 4c01e3d5..f761afb1 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -22,10 +22,10 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade { /** * See the status of one or all plugins. * - * @synopsis [] [--with-version] + * @synopsis [] */ - function status( $args, $assoc_args ) { - parent::status( $args, $assoc_args ); + function status( $args ) { + parent::status( $args ); } protected function status_single( $args ) {