Open schmich opened 6 years ago
@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". No promises though on when this would be implemented: I've been very bad a keeping them in the past 😆
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.