mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
Add example for option with argument choices
This commit is contained in:
@@ -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.
|
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
|
Setting number of invocations
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user