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

Feature Request: All-or-none structs #535

Open
formlogic-robert opened this issue Dec 20, 2023 · 1 comment
Open

Feature Request: All-or-none structs #535

formlogic-robert opened this issue Dec 20, 2023 · 1 comment

Comments

@formlogic-robert
Copy link

This is a small idea as it relates to the use of structopt in production environments.

It would be useful if a struct, in a multi-nested struct configuration, could be flagged to require all of its options to be provided whenever at least one of them is, or none at all. The usefulness of this is to prevent partial configurations in production environments which can lead to difficult-to-debug issues.

The feature would be used by specifying all_or_none in the struct trait's parameters:

#[derive(StructOpt)]
#[StructOpt(all_or_none)]

This saves having to write many required_if statements for all permutations of default parameters. If you specified a single parameter, but not other required parameters, regardless of whether they have defaults, the argument parsing would fail.

@epage
Copy link
Contributor

epage commented Dec 20, 2023

Note that structopt has been pulled into clap as of v3 and all future development is happening within clap. See #525

Something like this might be able to be done with ArgGroups in clap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants