File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -79,3 +79,23 @@ Feature: Runner WP-CLI
7979 Did you mean 'meta'?
8080 """
8181 And the return code should be 1
82+
83+ Scenario : Suggest 'wp term <command>' when an invalid taxonomy command is run
84+ Given a WP install
85+
86+ When I try `wp category list`
87+ Then STDERR should contain:
88+ """
89+ Did you mean 'wp term <command>'?
90+ """
91+ And the return code should be 1
92+
93+ Scenario : Suggest 'wp post <command>' when an invalid post type command is run
94+ Given a WP install
95+
96+ When I try `wp page create`
97+ Then STDERR should contain:
98+ """
99+ Did you mean 'wp post --post_type=page <command>'?
100+ """
101+ And the return code should be 1
Original file line number Diff line number Diff line change @@ -396,6 +396,16 @@ public function find_command_to_run( $args ) {
396396
397397 $ suggestion = $ this ->get_subcommand_suggestion ( $ full_name , $ command );
398398
399+ // If the functions are available, it means WordPress is available
400+ // and has already been loaded.
401+ if ( function_exists ( '\taxonomy_exists ' ) ) {
402+ if ( \taxonomy_exists ( $ cmd_path [0 ] ) ) {
403+ $ suggestion = 'wp term <command> ' ;
404+ } elseif ( \post_type_exists ( $ cmd_path [0 ] ) ) {
405+ $ suggestion = "wp post --post_type= {$ cmd_path [0 ]} <command> " ;
406+ }
407+ }
408+
399409 return sprintf (
400410 "'%s' is not a registered wp command. See 'wp help' for available commands.%s " ,
401411 $ full_name ,
You can’t perform that action at this time.
0 commit comments