WP_CLI

Runner::enumerate_commands()privateWP-CLI 1.0

Recursive method to enumerate all known commands.

Method of the class: Runner{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->enumerate_commands( $command, $list, $parent );
$command(CompositeCommand) (required)
Composite command to recurse over.
$list(array) (required)
Reference to list accumulating results.
$parent(string)
Parent command to use as prefix.
Default: ''

Runner::enumerate_commands() code WP-CLI 2.8.0-alpha

private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' ) {
	foreach ( $command->get_subcommands() as $subcommand ) {
		/** @var CompositeCommand $subcommand */
		$command_string = empty( $parent )
			? $subcommand->get_name()
			: "{$parent} {$subcommand->get_name()}";

		$list[] = $command_string;

		$this->enumerate_commands( $subcommand, $list, $command_string );
	}
}