Skip to content

Commit 9c1f144

Browse files
authored
Suggest 'network meta' intead of 'network option' (#5879)
* Suggest 'network meta' intead of 'network option' * Add feature test
1 parent 369e5a2 commit 9c1f144

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

features/runner.feature

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,15 @@ Feature: Runner WP-CLI
6767
Then STDERR should contain:
6868
"""
6969
The --path parameter cannot be empty when provided
70-
"""
70+
"""
71+
72+
Scenario: Suggest 'meta' when 'option' subcommand is run
73+
Given a WP install
74+
75+
When I try `wp network option`
76+
Then STDERR should contain:
77+
"""
78+
Error: 'option' is not a registered subcommand of 'network'. See 'wp help network' for available subcommands.
79+
Did you mean 'meta'?
80+
"""
81+
And the return code should be 1

php/WP_CLI/Runner.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ public function find_command_to_run( $args ) {
372372
$child = array_pop( $cmd_path );
373373
$parent_name = implode( ' ', $cmd_path );
374374
$suggestion = $this->get_subcommand_suggestion( $child, $command );
375+
376+
if ( 'network' === $parent_name && 'option' === $child ) {
377+
$suggestion = 'meta';
378+
}
379+
375380
return sprintf(
376381
"'%s' is not a registered subcommand of '%s'. See 'wp help %s' for available subcommands.%s",
377382
$child,

0 commit comments

Comments
 (0)