From 9a30af2cbe8a724a957fd3c97166cc595d4024b0 Mon Sep 17 00:00:00 2001 From: scribu Date: Thu, 12 Sep 2013 00:31:27 +0300 Subject: [PATCH] first pass at extracting synopsis from longdesc --- php/WP_CLI/Dispatcher/Subcommand.php | 13 +++++++++++-- php/commands/core.php | 8 +++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/php/WP_CLI/Dispatcher/Subcommand.php b/php/WP_CLI/Dispatcher/Subcommand.php index c5d4c0c1..e51f1f70 100644 --- a/php/WP_CLI/Dispatcher/Subcommand.php +++ b/php/WP_CLI/Dispatcher/Subcommand.php @@ -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() { diff --git a/php/commands/core.php b/php/commands/core.php index 5fb0c463..8657cf80 100644 --- a/php/commands/core.php +++ b/php/commands/core.php @@ -14,21 +14,19 @@ class Core_Command extends WP_CLI_Command { * * ## OPTIONS * - * --locale= + * [--locale=] * : Select which language you want to download. * - * --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=] [--version=] [--path=] [--force] - * * @when before_wp_load */ public function download( $args, $assoc_args ) { -- 2.11.0