-
Notifications
You must be signed in to change notification settings - Fork 55
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Position-independent options #64
Comments
@schmich Thank you for your kind words and for raising this issue. It's been a while now that I have been thinking about this idea, ie. something similar to Cobra's persistent flags. I'm accepting this feature request as I agree it's a "very nice to have". |
I appreciate the consideration, and I totally understand the "no promises" aspect. |
@jawher Is there any news about this feature? |
@mozillazg sorry, but I haven't been able to look at this yet. |
From what I can tell, there is no way to have a single-declaration global option that applies across all subcommands (i.e. its position on the command-line doesn't matter).
For example, let's say I have a command-line program
foo
which has subcommandbar
which has subcommandbaz
. I can invoke this asfoo bar baz
.Now, let's say I wanted to add a verbose logging flag
-v
which applies regardless of command/subcommand. Ideally, then, the following would be equivalent (I could specify the flag anywhere on the command-line):foo -v bar baz
foo bar -v baz
foo bar baz -v
I'd like to do this without having to define a
BoolOpt
onfoo
,bar
, andbaz
. Is there currently a way to do this by just defining a single globalBoolOpt
?In my actual use case, I have four levels of commands (i.e.
foo bar baz quux --opt waldo
). I would like to be able to specify verbosity (-v
,-vv
,-vvv
) as well as remote connection strings (--connection tcp://192.168.1.100:9000
) without needing to worry about their position.Thanks for your work on this library. It's a boon for the community, and I find myself reaching for it often.
The text was updated successfully, but these errors were encountered: