Skip to content

Commit

Permalink
Suggest 'network meta' intead of 'network option' (wp-cli#5879)
Browse files Browse the repository at this point in the history
* Suggest 'network meta' intead of 'network option'

* Add feature test
  • Loading branch information
shawnhooper authored Nov 21, 2023
1 parent 369e5a2 commit 9c1f144
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion features/runner.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@ Feature: Runner WP-CLI
Then STDERR should contain:
"""
The --path parameter cannot be empty when provided
"""
"""

Scenario: Suggest 'meta' when 'option' subcommand is run
Given a WP install

When I try `wp network option`
Then STDERR should contain:
"""
Error: 'option' is not a registered subcommand of 'network'. See 'wp help network' for available subcommands.
Did you mean 'meta'?
"""
And the return code should be 1
5 changes: 5 additions & 0 deletions php/WP_CLI/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ public function find_command_to_run( $args ) {
$child = array_pop( $cmd_path );
$parent_name = implode( ' ', $cmd_path );
$suggestion = $this->get_subcommand_suggestion( $child, $command );

if ( 'network' === $parent_name && 'option' === $child ) {
$suggestion = 'meta';
}

return sprintf(
"'%s' is not a registered subcommand of '%s'. See 'wp help %s' for available subcommands.%s",
$child,
Expand Down

0 comments on commit 9c1f144

Please sign in to comment.