OSDN Git Service

show validation warnings only when generating man pages. see #298
authorscribu <mail@scribu.net>
Tue, 12 Feb 2013 02:27:01 +0000 (04:27 +0200)
committerscribu <mail@scribu.net>
Tue, 12 Feb 2013 02:27:54 +0000 (04:27 +0200)
php/WP_CLI/Dispatcher/CompositeCommand.php
php/WP_CLI/Dispatcher/Subcommand.php

index e0ff1f6..897992b 100644 (file)
@@ -78,7 +78,7 @@ class CompositeCommand extends AbstractCommandContainer implements Documentable
                $str = array();
 
                foreach ( $this->subcommands as $subcommand ) {
-                       $str[] = $subcommand->get_full_synopsis();
+                       $str[] = $subcommand->get_full_synopsis( true );
                }
 
                return implode( "\n\n", $str );
index db17c4d..80d43f6 100644 (file)
@@ -14,25 +14,27 @@ class Subcommand implements Command, AtomicCommand, Documentable {
        }
 
        function show_usage( $prefix = 'usage: ' ) {
-               \WP_CLI::line( $prefix . $this->get_full_synopsis( false ) );
+               \WP_CLI::line( $prefix . $this->get_full_synopsis() );
        }
 
        function get_shortdesc() {
                return $this->docparser->get_shortdesc();
        }
 
-       function get_full_synopsis( $validate = true ) {
+       function get_full_synopsis( $validate = false ) {
                $full_name = implode( ' ', get_path( $this ) );
                $synopsis = $this->get_synopsis();
 
-               $tokens = \WP_CLI\SynopsisParser::parse( $synopsis );
+               if ( $validate ) {
+                       $tokens = \WP_CLI\SynopsisParser::parse( $synopsis );
 
-               foreach ( $tokens as $token ) {
-                       if ( 'unknown' == $token['type'] ) {
-                               \WP_CLI::warning( sprintf(
-                                       "Invalid token '%s' in synopsis for '%s'",
-                                       $token['token'], $full_name
-                               ) );
+                       foreach ( $tokens as $token ) {
+                               if ( 'unknown' == $token['type'] ) {
+                                       \WP_CLI::warning( sprintf(
+                                               "Invalid token '%s' in synopsis for '%s'",
+                                               $token['token'], $full_name
+                                       ) );
+                               }
                        }
                }