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:
Paul Ouellette
2019-12-13 21:46:43 -05:00
parent ad404c06ec
commit 20c14453fd
5 changed files with 96 additions and 11 deletions

View File

@@ -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
----------------------------

View File

@@ -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