-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display global flags in subcommand #734
Comments
|
I run into the same issue. I was expecting to see the option
Just to be clear, it is not a question of defining a global flag as suggested in the previous comment. It is about the printed help. |
Mostly for bookkeeping, I want to mention that this is conceptually related to my desire to expand global flags support for v3 #833 |
This feature is now |
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else. |
I'm not sure if this is still relevant as of v2? |
This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant. |
This issue is still present in v2. |
Thanks for the confirmation! 👍 |
I did a simple hack to always show the app global flags by overriding the globalOptionsTemplate := `{{if .VisibleFlags}}GLOBAL OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}
{{end}}
`
app := &cli.App {...}
origHelpPrinterCustom := cli.HelpPrinterCustom
defer func() {
cli.HelpPrinterCustom = origHelpPrinterCustom
}()
cli.HelpPrinterCustom = func(out io.Writer, templ string, data interface{}, customFuncs map[string]interface{}) {
origHelpPrinterCustom(out, templ, data, customFuncs)
if data != app {
origHelpPrinterCustom(app.Writer, globalOptionsTemplate, app, nil)
}
}
if err := app.Run(os.Args); err != nil {
//...
} |
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else. |
Closing this as it has become stale. |
I had a similar requirement. Is there any progress on this? |
It would be better if the global flags worked after a subcommand, optionally. In our tool it makes much more sense to do |
Is it possible to display higher-level flags in a subcommand?
e.g., given:
Is it possible for
verbose
to be displayed instatus
's help command without redefining the flag?The text was updated successfully, but these errors were encountered: