Add a "top-level" annotation to hide persistent flags#1106
Add a "top-level" annotation to hide persistent flags#1106thaJeztah merged 1 commit intodocker:masterfrom
Conversation
…mmands, excepting some specific commands, while printing help Fixes issue docker#1099 Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
| f.Hidden = true | ||
| } | ||
| // root command shows all top-level flags | ||
| if cmd.Parent() != nil { |
There was a problem hiding this comment.
I take it the default is false for f.Hidden, therefore --orchestrator is displayed by docker --help (i.e. when cmd.Parent() is nil), is this what we want?
There was a problem hiding this comment.
Yes, I think that's the desired behavior, it's possible to set it as global flag (i.e., docker --orchestrator=foo stack deploy), but when showing help for (e.g.) docker stack deploy we show it as a flag for that command, so: docker stack deploy --orchestrator=foo
Is that what you meant?
There was a problem hiding this comment.
Yes, I find it a bit odd that it can be set as a global flag given that it then has no effect and is ignored for most of the sub-commands, however it's out of the scope of this PR anyway.
There was a problem hiding this comment.
Not a big fan of the top level options as well, although they can be handy for making shell aliases (alias dockerk -> docker --orchestrator=foo --host=bla)
There was a problem hiding this comment.
Yep that's what we want, so "top level" flags are shown in the root command help (docker --help), hidden in all sub commands help but still available, excepting the one declared in the annotations.
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM. It's a bit quirky, but we can always find a better solution.
In future most commands will support orchestrator, so probably becomes less of an issue
|
Merging, but @mat007 let me know if there's still something we should address |
- What I did
I added a "top-level" annotation to hide persistent flags in all sub-commands, excepting some specific commands, while printing help.
Fixes issue #1099.
- How to verify it
- Description for the changelog
--orchestratorflag is showing up on too many commands #1099)- A picture of a cute animal (not mandatory but encouraged)