Command::allow_missing_positional
allow_missing_positional
Section titled “allow_missing_positional ”Allows one to implement two styles of CLIs where positionals can be used out of order.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”name = "myprog"allow-missing-positional = true[args]arg1 = {}arg2 = { required = true }
name: myprogallow-missing-positional: trueargs: arg1: {} arg2: required: true
{ "name": "myprog", "allow-missing-positional": true, "args": { "arg1": {}, "arg2": { "required": true } }}
myprog other
Output
Section titled “Output”claptrap_arg2='other'
Example 2
Section titled “Example 2”name = "myprog"allow-missing-positional = true[args]foo = {}bar = {}baz = { action = "set", num-args = "1.." }
name: myprogallow-missing-positional: trueargs: foo: {} bar: {} baz: action: set num-args: 1..
{ "name": "myprog", "allow-missing-positional": true, "args": { "foo": {}, "bar": {}, "baz": { "action": "set", "num-args": "1.." } }}
myprog foo bar baz1 baz2 baz3
Output
Section titled “Output”claptrap_foo='foo'claptrap_bar='bar'claptrap_baz=('baz1' 'baz2' 'baz3')
Example 3
Section titled “Example 3”name = "myprog"allow-missing-positional = true[args]foo = {}bar = {}baz = { action = "set", num-args = "1.." }
name: myprogallow-missing-positional: trueargs: foo: {} bar: {} baz: action: set num-args: 1..
{ "name": "myprog", "allow-missing-positional": true, "args": { "foo": {}, "bar": {}, "baz": { "action": "set", "num-args": "1.." } }}
myprog -- baz1 baz2 baz3
Output
Section titled “Output”claptrap_baz=('baz1' 'baz2' 'baz3')
Example 4
Section titled “Example 4”name = "myprog"allow-missing-positional = true[args]arg1 = { default-value = "something" }arg2 = { required = true }
name: myprogallow-missing-positional: trueargs: arg1: default-value: something arg2: required: true
{ "name": "myprog", "allow-missing-positional": true, "args": { "arg1": { "default-value": "something" }, "arg2": { "required": true } }}
myprog other
Output
Section titled “Output”claptrap_arg2='other'claptrap_arg1='something'