WP_CLI\Dispatcher

CommandNamespace::show_usage()publicWP-CLI 1.0

Show the usage for all subcommands contained by the composite command.

Method of the class: CommandNamespace{}

No Hooks.

Return

null. Nothing (null).

Usage

$CommandNamespace = new CommandNamespace();
$CommandNamespace->show_usage();

CommandNamespace::show_usage() code WP-CLI 2.8.0-alpha

public function show_usage() {
	$methods = $this->get_subcommands();

	$i     = 0;
	$count = 0;

	foreach ( $methods as $subcommand ) {
		$prefix = ( 0 === $i ) ? 'usage: ' : '   or: ';
		$i++;

		if ( \WP_CLI::get_runner()->is_command_disabled( $subcommand ) ) {
			continue;
		}

		\WP_CLI::line( $subcommand->get_usage( $prefix ) );
		$count++;
	}

	$cmd_name = implode( ' ', array_slice( get_path( $this ), 1 ) );
	$message  = $count > 0
		? "See 'wp help $cmd_name <command>' for more information on a specific command."
		: "The namespace $cmd_name does not contain any usable commands in the current context.";

	\WP_CLI::line();
	\WP_CLI::line( $message );

}