Arg::requires_ifs
requires_ifs
Section titled “requires_ifs ”Allows multiple conditional requirements.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”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 = {}
name: progargs: config: long: config action: set requires-ifs: - arg: opt value: special.conf - arg: other value: other.conf opt: long: option action: set other: {}
{ "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": {} }}
prog --config other.conf
Output
Section titled “Output”error: the following required arguments were not provided: <other>
Usage: prog --config <config> <other>
For more information, try '--help'.
Example 2
Section titled “Example 2”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 = {}
name: progargs: config: long: config action: set requires-ifs: - arg: opt value: special.conf - arg: other value: other.conf opt: long: option action: set other: {}
{ "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": {} }}
prog --config special.conf
Output
Section titled “Output”error: the following required arguments were not provided: --option <opt>
Usage: prog --option <opt> --config <config> [other]
For more information, try '--help'.
Example 3
Section titled “Example 3”name = "prog"[args]config = { long = "config", action = "set", requires-ifs = [{ arg = "input" }, { arg = "output" }] }input = {}output = {}
name: progargs: config: long: config action: set requires-ifs: - arg: input - arg: output input: {} output: {}
{ "name": "prog", "args": { "config": { "long": "config", "action": "set", "requires-ifs": [ { "arg": "input" }, { "arg": "output" } ] }, "input": {}, "output": {} }}
prog --config file.conf in.txt out.txt
Output
Section titled “Output”claptrap_config='file.conf'claptrap_input='in.txt'claptrap_output='out.txt'
Example 4
Section titled “Example 4”name = "prog"[args]config = { long = "config", action = "set", requires-ifs = [{ arg = "input" }, { arg = "output" }] }input = {}output = {}
name: progargs: config: long: config action: set requires-ifs: - arg: input - arg: output input: {} output: {}
{ "name": "prog", "args": { "config": { "long": "config", "action": "set", "requires-ifs": [ { "arg": "input" }, { "arg": "output" } ] }, "input": {}, "output": {} }}
prog --config file.conf in.txt
Output
Section titled “Output”error: the following required arguments were not provided: <output>
Usage: prog --config <config> <input> <output>
For more information, try '--help'.