Skip to content

Arg::requires_ifs

since 0.1.0

Allows multiple conditional requirements.

name = "prog"
[args]
config = { long = "config", action = "set", requires-ifs = [{ arg = "opt", value = "special.conf" }, { arg = "other", value = "other.conf" }] }
opt = { long = "option", action = "set" }
other = {}
Terminal window
prog --config other.conf
Terminal window
error: the following required arguments were not provided:
<other>
Usage: prog --config <config> <other>
For more information, try '--help'.
name = "prog"
[args]
config = { long = "config", action = "set", requires-ifs = [{ arg = "opt", value = "special.conf" }, { arg = "other", value = "other.conf" }] }
opt = { long = "option", action = "set" }
other = {}
Terminal window
prog --config special.conf
Terminal window
error: the following required arguments were not provided:
--option <opt>
Usage: prog --option <opt> --config <config> [other]
For more information, try '--help'.
name = "prog"
[args]
config = { long = "config", action = "set", requires-ifs = [{ arg = "input" }, { arg = "output" }] }
input = {}
output = {}
Terminal window
prog --config file.conf in.txt out.txt
Terminal window
claptrap_config='file.conf'
claptrap_input='in.txt'
claptrap_output='out.txt'
name = "prog"
[args]
config = { long = "config", action = "set", requires-ifs = [{ arg = "input" }, { arg = "output" }] }
input = {}
output = {}
Terminal window
prog --config file.conf in.txt
Terminal window
error: the following required arguments were not provided:
<output>
Usage: prog --config <config> <input> <output>
For more information, try '--help'.