structopt icon indicating copy to clipboard operation
structopt copied to clipboard

Support conflicts_with with flattened field.

Open ababo opened this issue 3 years ago • 1 comments

I would like to have an ability to do something like this:

    #[structopt(long, conflicts_with = "bar")]
    pub foo: bool,

    #[structopt(flatten)]
    pub bar: BarParams,

This means that if foo flag is set no flag from bar can be used.

ababo avatar Mar 25 '22 20:03 ababo

As a heads up, structopt is in maintenance mode at this point and new development is happening in clap.

As for this specific request, this falls into a derive-implementation challenge. This requires some form of cross-struct communication. As immediately presented, we'd need a way to apply the bar group name to all of BarParams fields. Say we instead have BarParams implicitly create a group named BarParams. The challenge there is then with if the user does a flatten within BarParams, we'd need to recursively apply the group name which goes back to that first problem

epage avatar Mar 25 '22 20:03 epage