Arg::required_unless_present_any
required_unless_present_any
Section titled “required_unless_present_any ”Sets this arg as required unless any of the specified arguments are present at runtime.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”name = "prog"[args]cfg = { long = "config", required-unless-present-any = ["dbg", "infile"], action = "set" }dbg = { long = "debug", action = "set-true" }infile = { short = 'i', action = "set" }
name: progargs: cfg: long: config required-unless-present-any: - dbg - infile action: set dbg: long: debug action: set-true infile: short: i action: set
{ "name": "prog", "args": { "cfg": { "long": "config", "required-unless-present-any": [ "dbg", "infile" ], "action": "set" }, "dbg": { "long": "debug", "action": "set-true" }, "infile": { "short": "i", "action": "set" } }}
prog --debug
Output
Section titled “Output”claptrap_dbg='true'
Example 2
Section titled “Example 2”name = "prog"[args]cfg = { long = "config", required-unless-present-any = ["dbg", "infile"], action = "set" }dbg = { long = "debug", action = "set-true" }infile = { short = 'i', action = "set" }
name: progargs: cfg: long: config required-unless-present-any: - dbg - infile action: set dbg: long: debug action: set-true infile: short: i action: set
{ "name": "prog", "args": { "cfg": { "long": "config", "required-unless-present-any": [ "dbg", "infile" ], "action": "set" }, "dbg": { "long": "debug", "action": "set-true" }, "infile": { "short": "i", "action": "set" } }}
prog
Output
Section titled “Output”error: the following required arguments were not provided: --config <cfg>
Usage: prog --config <cfg>
For more information, try '--help'.