Document command_target

This commit is contained in:
mpeterv
2015-12-09 13:05:48 +03:00
parent 247ed9e874
commit 1fa69cbf30
2 changed files with 25 additions and 0 deletions

View File

@@ -35,6 +35,29 @@ A typo will result in an appropriate error message.
Error: unknown command 'instal' Error: unknown command 'instal'
Did you mean 'install'? Did you mean 'install'?
Getting name of selected command
--------------------------------
Use ``command_target`` property of the parser to store the name of used command in a field of the result table.
.. code-block:: lua
:linenos:
parser:command_target("command")
parser:command("install")
parser:command("remove")
::
$ lua script.lua install
.. code-block:: lua
{
install = true,
command = "install"
}
Adding elements to commands Adding elements to commands
--------------------------- ---------------------------

View File

@@ -176,6 +176,7 @@ Property Type
``require_command`` Boolean ``require_command`` Boolean
``handle_options`` Boolean ``handle_options`` Boolean
``add_help`` Boolean or string or table ``add_help`` Boolean or string or table
``command_target`` String
=================== ========================== =================== ==========================
Command properties Command properties
@@ -203,6 +204,7 @@ Property Type
``handle_options`` Boolean ``handle_options`` Boolean
``action`` Function ``action`` Function
``add_help`` Boolean or string or table ``add_help`` Boolean or string or table
``command_target`` String
=================== ========================== =================== ==========================
Argument properties Argument properties