Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest 'network meta' intead of 'network option' #5879

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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