Hide help flag from help output#645
Conversation
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Codecov Report
@@ Coverage Diff @@
## master #645 +/- ##
==========================================
- Coverage 49.4% 49.39% -0.01%
==========================================
Files 208 208
Lines 17194 17195 +1
==========================================
Hits 8494 8494
- Misses 8267 8268 +1
Partials 433 433 |
|
|
||
| rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage") | ||
| rootCmd.PersistentFlags().MarkShorthandDeprecated("help", "please use --help") | ||
| rootCmd.PersistentFlags().Lookup("help").Hidden = true |
There was a problem hiding this comment.
hm, didn't the .golden file need to be updated? https://github.com/docker/cli/pull/642/files#r147009761
There was a problem hiding this comment.
I expected it would, but it doesn't because of how the flags are applied.
This help flag is applied as a persistent flag to the root command, so when commands are added to the root, they inherit this version of the flag, and don't add the default.
In the test we are testing directly against the swarm update command, so the root command is not there to provide this flag. Cobra adds its own default help flag that is not hidden, so the test output still contains the --help flag.
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM, thanks for explaining!
Follow up to #642