WP_CLI
Runner::get_subcommand_suggestion()
Get a suggestion on similar (sub)commands when the user entered an unknown (sub)command.
Method of the class: Runner{}
No Hooks.
Return
String
. Suggestion that fits the user entry, or an empty string.
Usage
// 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(CompositeCommand)
- Root command to start search for suggestions at.
Default: null
Runner::get_subcommand_suggestion() 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 ); }