diff --git a/docsrc/commands.rst b/docsrc/commands.rst index e8b0493..91f1a38 100644 --- a/docsrc/commands.rst +++ b/docsrc/commands.rst @@ -35,6 +35,29 @@ A typo will result in an appropriate error message. Error: unknown command 'instal' 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 --------------------------- diff --git a/docsrc/misc.rst b/docsrc/misc.rst index d06cf7d..6a8bb10 100644 --- a/docsrc/misc.rst +++ b/docsrc/misc.rst @@ -176,6 +176,7 @@ Property Type ``require_command`` Boolean ``handle_options`` Boolean ``add_help`` Boolean or string or table +``command_target`` String =================== ========================== Command properties @@ -203,6 +204,7 @@ Property Type ``handle_options`` Boolean ``action`` Function ``add_help`` Boolean or string or table +``command_target`` String =================== ========================== Argument properties