-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Global flags are not all global #2361
Comments
/cc @suzmue |
For the record we can't move those flags to subcommands because it would be backwards incompatible. For example |
Sure makes sense. It would be nice to be more consistent for new flags, but the old ones are what they are, minus the clarity of when they are applicable, which can still be addressed with warnings, better flag descriptions, additional notes under --help. |
Should this stay open? |
Perhaps we keep this open until we've improved warnings on when flags won't actually be used? Might be worth to create a checklist in this issue to keep track (cc @polinasok). |
Due to some very old mistakes too many of Delve's flags are declared as persistent on cobra's root command. For example the headless flag is a global flag but does not apply to connect, dap or trace; the backend flag does not apply to replay, core and dap; etc. Almost all global flags should have been declared as local flags on individual subcommands. Unfortunately we can not change this without breaking backwards compatibility, for example: dlv --headless debug would not parse if headless was a flag of debug instead of a global flag. Instead we alter usage function and the markdown generation script to strategically hide the flags that don't apply. Fixes go-delve#2361
Due to some very old mistakes too many of Delve's flags are declared as persistent on cobra's root command. For example the headless flag is a global flag but does not apply to connect, dap or trace; the backend flag does not apply to replay, core and dap; etc. Almost all global flags should have been declared as local flags on individual subcommands. Unfortunately we can not change this without breaking backwards compatibility, for example: dlv --headless debug would not parse if headless was a flag of debug instead of a global flag. Instead we alter usage function and the markdown generation script to strategically hide the flags that don't apply. Fixes go-delve#2361
Due to some very old mistakes too many of Delve's flags are declared as persistent on cobra's root command. For example the headless flag is a global flag but does not apply to connect, dap or trace; the backend flag does not apply to replay, core and dap; etc. Almost all global flags should have been declared as local flags on individual subcommands. Unfortunately we can not change this without breaking backwards compatibility, for example: dlv --headless debug would not parse if headless was a flag of debug instead of a global flag. Instead we alter usage function and the markdown generation script to strategically hide the flags that don't apply. Fixes go-delve#2361
Due to some very old mistakes too many of Delve's flags are declared as persistent on cobra's root command. For example the headless flag is a global flag but does not apply to connect, dap or trace; the backend flag does not apply to replay, core and dap; etc. Almost all global flags should have been declared as local flags on individual subcommands. Unfortunately we can not change this without breaking backwards compatibility, for example: dlv --headless debug would not parse if headless was a flag of debug instead of a global flag. Instead we alter usage function and the markdown generation script to strategically hide the flags that don't apply. Fixes #2361
I am noticing this in the context of dlv-dap, but this is true for other modes as well (e.g. build flags with exec, attach, etc). Also, as new flags get added, it is not clear if they are global and always apply as well.
It might be nice to have a map of subcommands and applicable flags and use that to set them. But if it is too tedious to add almost-global flags multiple times for the individual commands, then perhaps each such flag should mention in the description what subcommands it doesn't apply to? Or maybe each subcommand that ignores it should print a warning that the flag is ignored (either because the feature is not yet supported or because it doesn't make sense at all)?
In particular, based on
dlv dap --help
:Global Flags:
The text was updated successfully, but these errors were encountered: