WP_CLI::line( $name . ' ' . implode( ' ', array_keys( $subcommands ) ) );
}
}
-
- static function man( $args ) {
- if ( '' === exec( 'which ronn' ) ) {
- WP_CLI::error( '`ronn` executable not found.' );
- }
-
- $arg_copy = $args;
-
- $command = WP_CLI::$root;
-
- while ( !empty( $args ) && $command && $command instanceof Dispatcher\CommandContainer ) {
- $command = $command->find_subcommand( $args );
- }
-
- if ( !$command )
- WP_CLI::error( sprintf( "'%s' command not found.",
- implode( ' ', $arg_copy ) ) );
-
- foreach ( WP_CLI::get_man_dirs() as $dest_dir => $src_dir ) {
- WP_CLI\Man\generate( $src_dir, $dest_dir, $command );
- }
- }
}
}
private function _run_command() {
- // Handle --man parameter
- if ( isset( $this->assoc_args['man'] ) ) {
- \WP_CLI\InternalFlags::man( $this->arguments );
- exit;
- }
-
WP_CLI::run_command( $this->arguments, $this->assoc_args );
}
<?php
-use \WP_CLI\Dispatcher\CommandContainer;
-
class Help_Command extends WP_CLI_Command {
/**
* Get help on a certain topic.
*
- * @synopsis [<command>]
+ * @synopsis [<command>] [--gen]
*/
- function __invoke( $args ) {
+ function __invoke( $args, $assoc_args ) {
+ if ( isset( $assoc_args['gen'] ) )
+ $this->generate( $args );
+ else
+ $this->show( $args );
+ }
+
+ private function show( $args ) {
if ( \WP_CLI\Man\maybe_show_manpage( $args ) ) {
exit;
}
\WP_CLI::error( sprintf( "'%s' is not a registered wp command.", $args[0] ) );
}
}
+
+ private function generate( $args ) {
+ if ( '' === exec( 'which ronn' ) ) {
+ WP_CLI::error( '`ronn` executable not found.' );
+ }
+
+ $arg_copy = $args;
+
+ $command = WP_CLI\Utils\find_subcommand( $args );
+
+ if ( !$command ) {
+ WP_CLI::error( sprintf( "'%s' command not found.",
+ implode( ' ', $arg_copy ) ) );
+ }
+
+ foreach ( WP_CLI::get_man_dirs() as $dest_dir => $src_dir ) {
+ WP_CLI\Man\generate( $src_dir, $dest_dir, $command );
+ }
+
+ exit;
+ }
}
WP_CLI::add_command( 'help', 'Help_Command' );