From 9c1f144cc2b65d65765cd821f9bd33d17a9b6644 Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Tue, 21 Nov 2023 06:36:07 -0500 Subject: [PATCH] Suggest 'network meta' intead of 'network option' (#5879) * Suggest 'network meta' intead of 'network option' * Add feature test --- features/runner.feature | 13 ++++++++++++- php/WP_CLI/Runner.php | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/features/runner.feature b/features/runner.feature index 5d5cd1368c..9f1c2b7d52 100644 --- a/features/runner.feature +++ b/features/runner.feature @@ -67,4 +67,15 @@ Feature: Runner WP-CLI Then STDERR should contain: """ The --path parameter cannot be empty when provided - """ \ No newline at end of file + """ + + 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 diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index a497dae978..4534e5c702 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -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,