How to associate a category of flags to a category of commands? #2246
Unanswered
louisroyer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have multiple top-level commands (that I don't want to become sub-commands), some of them require a common flag
config, while some other must be able to run without this argument.The naive approach would be to make the flag optional manually check in each command's Action if
cmd.String("config") == "", but this is a lot of duplicated code, and the resulting generated help text is not making conditions to include this flag obvious from user point of view.I also tried the following, but apparently flags categories and commands categories are just cues in the generated help text and have no effect on the flag parsing:
What would be the best way to solve this issue?
Beta Was this translation helpful? Give feedback.
All reactions