OSDN Git Service

first pass at extracting synopsis from longdesc
authorscribu <mail@scribu.net>
Wed, 11 Sep 2013 21:31:27 +0000 (00:31 +0300)
committerscribu <mail@scribu.net>
Wed, 11 Sep 2013 21:31:27 +0000 (00:31 +0300)
php/WP_CLI/Dispatcher/Subcommand.php
php/commands/core.php

index c5d4c0c..e51f1f7 100644 (file)
@@ -12,12 +12,21 @@ class Subcommand extends CompositeCommand {
        private $when_invoked;
 
        function __construct( $parent, $name, $docparser, $when_invoked ) {
+               parent::__construct( $parent, $name, $docparser );
+
                $this->when_invoked = $when_invoked;
 
-               $this->synopsis = $docparser->get_synopsis();
                $this->alias = $docparser->get_tag( 'alias' );
 
-               parent::__construct( $parent, $name, $docparser );
+               $this->synopsis = $docparser->get_synopsis();
+               if ( !$this->synopsis && $this->longdesc ) {
+                       $this->synopsis = self::extract_synopsis( $this->longdesc );
+               }
+       }
+
+       private static function extract_synopsis( $longdesc ) {
+               preg_match_all( '/(.+)\n:/', $longdesc, $matches );
+               return implode( ' ', $matches[1] );
        }
 
        function get_synopsis() {
index 5fb0c46..8657cf8 100644 (file)
@@ -14,21 +14,19 @@ class Core_Command extends WP_CLI_Command {
         *
         * ## OPTIONS
         *
-        * --locale=<locale>
+        * [--locale=<locale>]
         * : Select which language you want to download.
         *
-        * --version=<version>
+        * [--version=<version>]
         * : Select which version you want to download.
         *
-        * --force
+        * [--force]
         * : Overwrites existing files, if present.
         *
         * ## EXAMPLES
         *
         *     wp core download --version=3.3
         *
-        * @synopsis [--locale=<locale>] [--version=<version>] [--path=<path>] [--force]
-        *
         * @when before_wp_load
         */
        public function download( $args, $assoc_args ) {