Arg::requires_if
requires_if
Section titled “requires_if ”Require another argument if this arg matches the ArgPredicate.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”name = "prog"[args]config = { long = "config", action = "set", requires-if = { arg = "other", value = "my.cfg" } }other = {}
name: progargs: config: long: config action: set requires-if: arg: other value: my.cfg other: {}
{ "name": "prog", "args": { "config": { "long": "config", "action": "set", "requires-if": { "arg": "other", "value": "my.cfg" } }, "other": {} }}
prog --config some.cfg
Output
Section titled “Output”claptrap_config='some.cfg'
Example 2
Section titled “Example 2”name = "prog"[args]config = { long = "config", action = "set", requires-if = { arg = "other", value = "my.cfg" } }other = {}
name: progargs: config: long: config action: set requires-if: arg: other value: my.cfg other: {}
{ "name": "prog", "args": { "config": { "long": "config", "action": "set", "requires-if": { "arg": "other", "value": "my.cfg" } }, "other": {} }}
prog --config my.cfg
Output
Section titled “Output”error: the following required arguments were not provided: <other>
Usage: prog --config <config> <other>
For more information, try '--help'.