Mutually exclusive groupsΒΆ
A group of arguments and options can be marked as mutually exclusive using :mutex(argument_or_option, ...)
method of the Parser class.
1parser:mutex(
2 parser:argument "input"
3 :args "?",
4 parser:flag "--process-stdin"
5)
6
7parser:mutex(
8 parser:flag "-q --quiet",
9 parser:flag "-v --verbose"
10)
If more than one element of a mutually exclusive group is used, an error is raised.
$ lua script.lua -qv
Usage: script.lua ([-q] | [-v]) [-h] ([<input>] | [--process-stdin])
Error: option '-v' can not be used together with option '-q'
$ lua script.lua file --process-stdin
Usage: script.lua ([-q] | [-v]) [-h] ([<input>] | [--process-stdin])
Error: option '--process-stdin' can not be used together with argument 'input'