-
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
subcommands silently ignore app level flags #191
Comments
@lcowell you should be able to access |
Thanks @jszwedko! This does the trick for me. I think README.md should have some information about global vs. non-global flags because the solution was pretty clear once I had the information. |
I had this issue too and it confused me a lot. I would also susggest to remove the Global Methods completely and just pass the global options/flags to all sub commands plus any other additional options defined for sub command. You can define more for a sub command right? I didn't find out how to do that via the Readme. |
I do think that Commands should inherit app flags so that if you do this for example: ./boom --verbose info this should also work ./boom info --verbose Its not a matter of access; Its a matter that the all the flags get checked when parsing them. |
I agree as well, even if the maintainers feel differently it should be documented in the README that the accessor is |
Indeed it's really not clear, thought initially that it was a bug, came here looking for an existing issue. |
If maintainers wish to support this (parent flags always available to child contexts), then I think this could be pretty easily accomplished by adding a method similar to this...
and then changing the non-global lookups to use the above function in a similar fashion to how the global* lookups current work. Ex:
Another option would be to just add an additional set of lookup methods that behave this way:
|
This app (see below) has a
limit
flag and aninfo
command. If I call the app like this:The
limit
flag is not set when I call theinfo
action. If I move those flags to the command's definition, then I can call the app like this:However, in my real world use case, flags like limit apply to most, if not all the commands.
I think flags declared at the app level, should be available to any command and flags declared at the command level, should only be available to that particular command. I think that if a flag is not accepted, the user should be informed of this.
Thanks for building this awesome tool! Please let me know if there's anything else I can do to help.
Here's the code I'm referring to:
The text was updated successfully, but these errors were encountered: