Runner::get_subcommand_suggestion()privateWP-CLI 1.0

Get a suggestion on similar (sub)commands when the user entered an unknown (sub)command.

Method of the class: Runner{}

No Hooks.


String. Suggestion that fits the user entry, or an empty string.


// private - for code of main (parent) class only
$result = $this->get_subcommand_suggestion( $entry, $root_command );
$entry(string) (required)
User entry that didn't match an existing command.
Root command to start search for suggestions at.
Default: null

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

private function get_subcommand_suggestion( $entry, CompositeCommand $root_command = null ) {
	$commands = [];
	$this->enumerate_commands( $root_command ?: WP_CLI::get_root_command(), $commands );

	return Utils\get_suggestion( $entry, $commands, $threshold = 2 );