mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Merge remote-tracking branch 'luarocks/refs/pull/6/head'
This commit is contained in:
@@ -140,3 +140,43 @@ This can be changed using ``require_command`` property.
|
|||||||
local parser = argparse()
|
local parser = argparse()
|
||||||
:require_command(false)
|
:require_command(false)
|
||||||
parser:command "install"
|
parser:command "install"
|
||||||
|
|
||||||
|
Command summaries
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The description for commands shown in the parent parser help message can be set
|
||||||
|
with the ``summary`` property.
|
||||||
|
|
||||||
|
.. code-block:: lua
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
parser:command "install"
|
||||||
|
:summary "Install a rock."
|
||||||
|
:description "A long description for the install command."
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
$ lua script.lua --help
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
Usage: script.lua [-h] <command> ...
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this help message and exit.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
install Install a rock.
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
$ lua script.lua install --help
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
Usage: script.lua install [-h]
|
||||||
|
|
||||||
|
A long description for the install command.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this help message and exit.
|
||||||
|
@@ -201,6 +201,7 @@ Other properties:
|
|||||||
=========================== ==========================
|
=========================== ==========================
|
||||||
Property Type
|
Property Type
|
||||||
=========================== ==========================
|
=========================== ==========================
|
||||||
|
``summary`` String
|
||||||
``target`` String
|
``target`` String
|
||||||
``usage`` String
|
``usage`` String
|
||||||
``help`` String
|
``help`` String
|
||||||
|
@@ -306,6 +306,7 @@ local Command = class({
|
|||||||
multiname,
|
multiname,
|
||||||
typechecked("description", "string"),
|
typechecked("description", "string"),
|
||||||
typechecked("epilog", "string"),
|
typechecked("epilog", "string"),
|
||||||
|
typechecked("summary", "string"),
|
||||||
typechecked("target", "string"),
|
typechecked("target", "string"),
|
||||||
typechecked("usage", "string"),
|
typechecked("usage", "string"),
|
||||||
typechecked("help", "string"),
|
typechecked("help", "string"),
|
||||||
@@ -589,7 +590,7 @@ function Argument:_get_description()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Command:_get_description()
|
function Command:_get_description()
|
||||||
return self._description or ""
|
return self._summary or self._description or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function Option:_get_usage()
|
function Option:_get_usage()
|
||||||
|
Reference in New Issue
Block a user