Add example for option with argument choices

This commit is contained in:
Paul Ouellette
2019-05-30 01:37:01 -04:00
parent a8faa0b092
commit ec3d22f499

View File

@@ -112,6 +112,22 @@ Setting argument choices
The ``choices`` property can be used to specify a list of choices for an option argument in the same way as for arguments.
.. code-block:: lua
:linenos:
parser:option "--format"
:choices {"short", "medium", "full"}
.. code-block:: none
$ lua script.lua --format foo
.. code-block:: none
Usage: script.lua [-h] [--format {short,medium,full}]
Error: argument for option '--format' must be one of 'short', 'medium', 'full'
Setting number of invocations
-----------------------------