OSDN Git Service

remove $label parameter from logging methods
authorscribu <mail@scribu.net>
Fri, 6 Sep 2013 16:27:01 +0000 (19:27 +0300)
committerscribu <mail@scribu.net>
Fri, 6 Sep 2013 17:03:12 +0000 (20:03 +0300)
The label text and color are just a way to signal to the user the type of message.

Changing it can lead to confusion. Example:

    WP_CLI::error( 'Something bad happened!', 'Success' );

php/WP_CLI/Loggers/Quiet.php
php/WP_CLI/Loggers/Regular.php
php/class-wp-cli.php

index 926986c..6f32fbe 100644 (file)
@@ -8,16 +8,16 @@ class Quiet {
                // nothing
        }
 
-       function success( $message, $label ) {
+       function success( $message ) {
                // nothing
        }
 
-       function warning( $message, $label ) {
+       function warning( $message ) {
                // nothing
        }
 
-       function error( $message, $label ) {
-               fwrite( STDERR, \WP_CLI::colorize( "%R$label:%n $message\n" ) );
+       function error( $message ) {
+               fwrite( STDERR, \WP_CLI::colorize( "%RError:%n $message\n" ) );
        }
 }
 
index 56c63f5..b992faa 100644 (file)
@@ -12,16 +12,16 @@ class Regular {
                fwrite( STDOUT, $message . "\n" );
        }
 
-       function success( $message, $label ) {
-               $this->_line( $message, $label, '%G' );
+       function success( $message ) {
+               $this->_line( $message, 'Success', '%G' );
        }
 
-       function warning( $message, $label ) {
-               $this->_line( $message, $label, '%C', STDERR );
+       function warning( $message ) {
+               $this->_line( $message, 'Warning', '%C', STDERR );
        }
 
-       function error( $message, $label ) {
-               $this->_line( $message, $label, '%R', STDERR );
+       function error( $message ) {
+               $this->_line( $message, 'Error', '%R', STDERR );
        }
 }
 
index da3a32b..67d06ea 100644 (file)
@@ -120,31 +120,28 @@ class WP_CLI {
         * Display a success in the CLI and end with a newline
         *
         * @param string $message
-        * @param string $label
         */
-       static function success( $message, $label = 'Success' ) {
-               self::$logger->success( $message, $label );
+       static function success( $message ) {
+               self::$logger->success( $message );
        }
 
        /**
         * Display a warning in the CLI and end with a newline
         *
         * @param string $message
-        * @param string $label
         */
-       static function warning( $message, $label = 'Warning' ) {
-               self::$logger->warning( self::error_to_string( $message ), $label );
+       static function warning( $message ) {
+               self::$logger->warning( self::error_to_string( $message ) );
        }
 
        /**
         * Display an error in the CLI and end with a newline
         *
         * @param string $message
-        * @param string $label
         */
-       static function error( $message, $label = 'Error' ) {
+       static function error( $message ) {
                if ( ! isset( self::get_runner()->assoc_args[ 'completions' ] ) ) {
-                       self::$logger->error( self::error_to_string( $message ), $label );
+                       self::$logger->error( self::error_to_string( $message ) );
                }
 
                exit(1);