Skip to content

Arg::required_if_eq

since 0.1.0

This argument is required only if the specified arg is present at runtime and its value equals val.

name = "prog"
[args]
cfg = { long = "config", action = "set", required-if-eq = { arg = "other", value = "special" } }
other = { long = "other", action = "set" }
Terminal window
prog --other not-special
Terminal window
claptrap_other='not-special'
name = "prog"
[args]
cfg = { long = "config", action = "set", required-if-eq = { arg = "other", value = "special" } }
other = { long = "other", action = "set" }
Terminal window
prog --other special
Terminal window
error: the following required arguments were not provided:
--config <cfg>
Usage: prog --other <other> --config <cfg>
For more information, try '--help'.
name = "prog"
[args]
cfg = { long = "config", action = "set", required-if-eq = { arg = "other", value = "special" } }
other = { long = "other", action = "set", ignore-case = true }
Terminal window
prog --other SPECIAL
Terminal window
error: the following required arguments were not provided:
--config <cfg>
Usage: prog --other <other> --config <cfg>
For more information, try '--help'.
name = "prog"
[args]
cfg = { long = "config", action = "set", required-if-eq = { arg = "other", value = "special" } }
other = { long = "other", action = "set" }
Terminal window
prog --other SPECIAL
Terminal window
claptrap_other='SPECIAL'