Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4246715

Browse files
authored
Merge pull request wp-cli#5423 from wp-cli/feature/allow-suppressing-global-params
2 parents 97d30cb + 2f9e07a commit 4246715

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

features/help.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,40 @@ Feature: Get help about WP-CLI commands
5353
"""
5454
And STDERR should be empty
5555

56+
Scenario: Hide Global parameters when requested
57+
Given an empty directory
58+
59+
When I run `wp help`
60+
Then STDOUT should contain:
61+
"""
62+
GLOBAL PARAMETERS
63+
"""
64+
65+
And STDOUT should contain:
66+
"""
67+
--path
68+
"""
69+
70+
And STDOUT should contain:
71+
"""
72+
Path to the WordPress files.
73+
"""
74+
75+
When I run `WP_CLI_SUPPRESS_GLOBAL_PARAMS=true wp help`
76+
Then STDOUT should not contain:
77+
"""
78+
GLOBAL PARAMETERS
79+
"""
80+
81+
And STDOUT should not contain:
82+
"""
83+
--path
84+
"""
85+
And STDOUT should not contain:
86+
"""
87+
Path to the WordPress files.
88+
"""
89+
5690
# Prior to WP 4.3 widgets & others used PHP 4 style constructors and prior to WP 3.9 wpdb used the mysql extension which can all lead (depending on PHP version) to PHP Deprecated notices.
5791
@require-wp-4.3
5892
Scenario: Help for internal commands with WP

php/WP_CLI/Dispatcher/CompositeCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,14 @@ protected function get_global_params( $root_command = false ) {
296296
$synopsis = "--$key" . $details['runtime'];
297297
}
298298

299-
$binding['parameters'][] = array(
300-
'synopsis' => $synopsis,
301-
'desc' => $details['desc'],
302-
);
299+
// Check if global parameters synopsis should be displayed or not.
300+
if ( true !== (bool) getenv( 'WP_CLI_SUPPRESS_GLOBAL_PARAMS' ) ) {
301+
$binding['parameters'][] = array(
302+
'synopsis' => $synopsis,
303+
'desc' => $details['desc'],
304+
);
305+
$binding['has_parameters'] = true;
306+
}
303307
}
304308

305309
if ( $this->get_subcommands() ) {

templates/man-params.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77

88
{{/has_subcommands}}
9+
{{#has_parameters}}
910
## GLOBAL PARAMETERS
1011

1112
{{#parameters}}
1213
{{synopsis}}
1314
{{desc}}
1415

1516
{{/parameters}}
17+
{{/has_parameters}}
1618
{{#root_command}}
1719
Run 'wp help <command>' to get more information on a specific command.
1820

0 commit comments

Comments
 (0)