OSDN Git Service

replace get_extra_markdown() with get_longdesc()
authorscribu <mail@scribu.net>
Thu, 1 Aug 2013 21:57:32 +0000 (00:57 +0300)
committerscribu <mail@scribu.net>
Thu, 1 Aug 2013 21:57:32 +0000 (00:57 +0300)
php/WP_CLI/Dispatcher/CompositeCommand.php
php/WP_CLI/Dispatcher/RootCommand.php
php/commands/cli.php
php/commands/help.php

index 1aa21b5..98cbbe7 100644 (file)
@@ -17,6 +17,7 @@ class CompositeCommand {
                $this->name = $name;
 
                $this->shortdesc = $docparser->get_shortdesc();
+               $this->longdesc = $docparser->get_longdesc();
 
                $when_to_invoke = $docparser->get_tag( 'when' );
                if ( $when_to_invoke ) {
@@ -50,6 +51,10 @@ class CompositeCommand {
                return $this->shortdesc;
        }
 
+       function get_longdesc() {
+               return $this->longdesc;
+       }
+
        function get_synopsis() {
                return '<subcommand>';
        }
@@ -73,28 +78,6 @@ class CompositeCommand {
                \WP_CLI::line( "See 'wp help $this->name <subcommand>' for more information on a specific subcommand." );
        }
 
-       function get_extra_markdown() {
-               $md_file = self::find_extra_markdown_file( $this );
-               if ( !$md_file )
-                       return '';
-
-               return file_get_contents( $md_file );
-       }
-
-       private static function find_extra_markdown_file( $command ) {
-               $cmd_path = get_path( $command );
-               array_shift( $cmd_path ); // discard 'wp'
-               $cmd_path = implode( '-', $cmd_path );
-
-               foreach ( \WP_CLI::get_man_dirs() as $src_dir ) {
-                       $src_path = "$src_dir/$cmd_path.txt";
-                       if ( is_readable( $src_path ) )
-                               return $src_path;
-               }
-
-               return false;
-       }
-
        function find_subcommand( &$args ) {
                $name = array_shift( $args );
 
index 311d295..d65c79f 100644 (file)
@@ -17,7 +17,7 @@ class RootCommand extends CompositeCommand {
                $this->shortdesc = 'Manage WordPress through the command-line.';
        }
 
-       function get_extra_markdown() {
+       function get_longdesc() {
                $binding = array();
 
                foreach ( \WP_CLI::get_configurator()->get_spec() as $key => $details ) {
index a31493b..2f550c8 100644 (file)
@@ -14,6 +14,7 @@ class CLI_Command extends WP_CLI_Command {
                $dump = array(
                        'name' => $command->get_name(),
                        'description' => $command->get_shortdesc(),
+                       'longdesc' => $command->get_longdesc(),
                );
 
                foreach ( $command->get_subcommands() as $subcommand ) {
index 9b86c08..fb42b8a 100644 (file)
@@ -37,7 +37,7 @@ class Help_Command extends WP_CLI_Command {
        private static function show_help( $command ) {
                $out = self::get_initial_markdown( $command );
 
-               $out .= $command->get_extra_markdown();
+               $out .= $command->get_longdesc();
 
                // section headers
                $out = preg_replace( '/^## ([A-Z ]+)/m', '%9\1%n', $out );