Update documentation [ci skip]

This commit is contained in:
Peter Melnichenko
2018-04-12 14:02:37 +03:00
parent 9019b4fe3a
commit 99cdddbc9d
10 changed files with 417 additions and 144 deletions

View File

@@ -1,11 +1,17 @@
Mutually exclusive groups
=========================
A group of options can be marked as mutually exclusive using ``:mutex(option, ...)`` method of the Parser class.
A group of arguments and options can be marked as mutually exclusive using ``:mutex(argument_or_option, ...)`` method of the Parser class.
.. code-block:: lua
:linenos:
parser:mutex(
parser:argument "input"
:args "?",
parser:flag "--process-stdin"
)
parser:mutex(
parser:flag "-q --quiet",
parser:flag "-v --verbose"
@@ -13,12 +19,22 @@ A group of options can be marked as mutually exclusive using ``:mutex(option, ..
If more than one element of a mutually exclusive group is used, an error is raised.
::
.. code-block:: none
$ lua script.lua -qv
::
.. code-block:: none
Usage: script.lua ([-q] | [-v]) [-h]
Usage: script.lua ([-q] | [-v]) [-h] ([<input>] | [--process-stdin])
Error: option '-v' can not be used together with option '-q'
.. code-block:: none
$ lua script.lua file --process-stdin
.. code-block:: none
Usage: script.lua ([-q] | [-v]) [-h] ([<input>] | [--process-stdin])
Error: option '--process-stdin' can not be used together with argument 'input'