mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Added epilog field
This commit is contained in:
@@ -32,6 +32,23 @@ describe("tests related to help message generation", function()
|
||||
}, "\r\n"), parser:prepare():get_help())
|
||||
end)
|
||||
|
||||
it("uses description and epilog", function()
|
||||
local parser = Parser "foo"
|
||||
:description "A description. "
|
||||
:epilog "An epilog. "
|
||||
|
||||
assert.equal(table.concat({
|
||||
"Usage: foo [-h]",
|
||||
"",
|
||||
"A description. ",
|
||||
"",
|
||||
"Options: ",
|
||||
" -h, --help Show this help message and exit. ",
|
||||
"",
|
||||
"An epilog. "
|
||||
}, "\r\n"), parser:prepare():get_help())
|
||||
end)
|
||||
|
||||
it("creates correct help message for arguments", function()
|
||||
local parser = Parser "foo"
|
||||
parser:argument "first"
|
||||
|
@@ -51,7 +51,7 @@ local Parser = class {
|
||||
_require_command = true,
|
||||
_add_help = true,
|
||||
_fields = {
|
||||
"name", "description", "require_command",
|
||||
"name", "description", "epilog", "require_command",
|
||||
"action", "usage", "help", "add_help"
|
||||
}
|
||||
}:include(Declarative)
|
||||
@@ -60,9 +60,9 @@ local Command = Parser:extends {
|
||||
__name = "Command",
|
||||
_aliases = {},
|
||||
_fields = {
|
||||
"name", "aliases", "description", "target",
|
||||
"require_command", "action", "usage", "help",
|
||||
"add_help"
|
||||
"name", "aliases", "description", "epilog",
|
||||
"target", "require_command", "action", "usage",
|
||||
"help", "add_help"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +435,10 @@ function Parser:get_help()
|
||||
table.insert(blocks, table.concat(buf, "\r\n"))
|
||||
end
|
||||
|
||||
if self._epilog then
|
||||
table.insert(blocks, self._epilog)
|
||||
end
|
||||
|
||||
self._help = table.concat(blocks, "\r\n\r\n")
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user