# Clap and "sets" of requires command line args

I'm using Clap to parse my command line and need to support the following:

mycommand [--somearg1 value --alsorequired another value] | [--somearg2 value --requiredfor2 value]

Basically if --somearg1 is specified, then --alsorequired is required. But if --somearg2 is specified, --requiredfor2 is required.

I'd have thought that ArgGroups would cover this use case but it doesn't seem to address it.

Thanks! That helped a lot. Here is what I ended up with:

let matches = Command::new("prog")
.arg(arg!(--two <VALUE>).required(false).requires("three"))
.arg(arg!(--three <VALUE>))
.arg(arg!(--four <VALUE>).exclusive(true))
.get_matches();

So in this case --two requires --three and --four is exclusive.