Skip to content
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

Is a required ArgGroup only for the current SubCommand, or global? #439

Closed
matthiasbeyer opened this issue Mar 6, 2016 · 4 comments
Closed
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations

Comments

@matthiasbeyer
Copy link
Contributor

This is a bit unclear in the documentation (at least for me):

If I have an ArgGroup which is ::required(true) - does this mean this ArgGroup is required globally and a user must always provide these arguments? Or does it only apply to the SubCommand instance level above the ArgGroup instance?

E.G.:

App::new()
// ... args and subcommands
.subcommand(
    SubCommand::with_name("subcmd")
        .arg(Arg::with_name("foo")) // and more settings
        .arg(Arg::with_name("bar")) // and more settings
        .group(ArgGroup::new("foobar").args(&["foo", "bar"]).required(true))
)

Is "foo" or "bar" now enforced for app <flags>, or only for app subcmd <flags>?


If it is enforced globally: Feature request: flag for forcing ArgGroups only for the enclosing SubCommand.

@kbknapp
Copy link
Member

kbknapp commented Mar 8, 2016

@matthiasbeyer Sorry it took me so long to respond!

It means that either foo or bar must be present at runtime. It's a way of making one of the two args, but not both, be present. You can think of it like a "Make this arg required, if none of these other args are present" type setting.

Edit: And it's only for that subcommand instance, not the globally 😉

@kbknapp kbknapp changed the title [Question]: Is a required ArgGroup required only for the SubCommand or globally? Is a required ArgGroup only for the current SubCommand, or globally? Mar 8, 2016
@matthiasbeyer
Copy link
Contributor Author

And it's only for that subcommand instance, not the globally

Would be nice to state this explicitely in the docs! 👍

@kbknapp kbknapp changed the title Is a required ArgGroup only for the current SubCommand, or globally? Is a required ArgGroup only for the current SubCommand, or global? Mar 8, 2016
@kbknapp
Copy link
Member

kbknapp commented Mar 8, 2016

I'll mark this a docs update then, thanks for filing! 👍

@kbknapp kbknapp added C-enhancement Category: Raise on the bar on expectations A-docs Area: documentation, including docs.rs, readme, examples, etc... D: easy and removed T: RFC / question labels Mar 8, 2016
@matthiasbeyer
Copy link
Contributor Author

Thanks for your awesome support!

@homu homu closed this as completed in 4ff0205 Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants