WP_CLI\Dispatcher

CompositeCommand::add_subcommand()publicWP-CLI 1.0

Add a named subcommand to this composite command's set of contained subcommands.

Method of the class: CompositeCommand{}

No Hooks.

Return

null. Nothing.

Usage

$CompositeCommand = new CompositeCommand();
$CompositeCommand->add_subcommand( $name, $command, $override );
$name(string) (required)
Represents how subcommand should be invoked
$command(Subcommand|CompositeCommand) (required)
Cub-command to add.
$override(true|false)
Whether to override an existing subcommand of the same name.
Default: true

CompositeCommand::add_subcommand() code WP-CLI 2.8.0-alpha

public function add_subcommand( $name, $command, $override = true ) {
	if ( $override || ! array_key_exists( $name, $this->subcommands ) ) {
		$this->subcommands[ $name ] = $command;
	}
}