mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Add hidden command and option aliases
Also auto-add an alias with dashes in place of underscores if an alias has an underscore.
This commit is contained in:
@@ -39,6 +39,41 @@ it is not included into help and usage messages, but otherwise works normally.
|
||||
deprecated_option = "value"
|
||||
}
|
||||
|
||||
Hiding option and command aliases
|
||||
---------------------------------
|
||||
|
||||
Hidden aliases can be added to an option or command by setting the
|
||||
``hidden_name`` property. Its value is interpreted in the same way as the
|
||||
``name`` property.
|
||||
|
||||
.. code-block:: lua
|
||||
:linenos:
|
||||
|
||||
parser:option "--server"
|
||||
:hidden_name "--from"
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
$ lua script.lua --help
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
Usage: script.lua [-h] [--server <server>]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit.
|
||||
--server <server>
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
$ lua script.lua --server foo
|
||||
$ lua script.lua --from foo
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
{
|
||||
server = "foo"
|
||||
}
|
||||
|
||||
Setting argument placeholder
|
||||
----------------------------
|
||||
|
@@ -200,6 +200,7 @@ Other properties:
|
||||
=========================== ==========================
|
||||
Property Type
|
||||
=========================== ==========================
|
||||
``hidden_name`` String
|
||||
``summary`` String
|
||||
``target`` String
|
||||
``usage`` String
|
||||
@@ -269,6 +270,7 @@ Other properties:
|
||||
=================== ==================
|
||||
Property Type
|
||||
=================== ==================
|
||||
``hidden_name`` String
|
||||
``target`` String
|
||||
``defmode`` String
|
||||
``show_default`` Boolean
|
||||
|
Reference in New Issue
Block a user