Structopt 'exactly one of'

Using StructOpt, is it possible to express a constraint that you have a set of arguments where you can only specify exactly one? For example, pacman operations where you can say "-S" or "-R" but not both. I'm aware of subcommands, but as far as I can tell, they can't be used as switches

clap allows arguments in an ArgGroup to conflict with each other: https://docs.rs/clap/2.33.3/clap/struct.ArgGroup.html#method.conflicts_with

You may be able to adapt the example at https://github.com/TeXitoi/structopt/blob/62f59d3bfd13c8802f4065d57805eb905c9ec4b7/examples/group.rs to use it with structopt.

1 Like