Split labels for multi-alias options into lines in help string

This commit is contained in:
Peter Melnichenko
2018-04-08 15:03:56 +03:00
parent 5c1a6896fc
commit 8baabbbe23
4 changed files with 137 additions and 24 deletions

View File

@@ -106,6 +106,55 @@ Options:
-h, --help Show this help message and exit.]], parser:get_help())
end)
it("puts different aliases on different lines if there are arguments", function()
local parser = Parser "foo"
parser:option "-o --output"
assert.equal([[
Usage: foo [-o <output>] [-h]
Options:
-o <output>,
--output <output>
-h, --help Show this help message and exit.]], parser:get_help())
end)
it("handles description with more lines than usage", function()
local parser = Parser "foo"
parser:option "-o --output"
:description [[
Sets output file.
If missing, 'a.out' is used by default.
If '-' is passed, output to stdount.
]]
assert.equal([[
Usage: foo [-o <output>] [-h]
Options:
-o <output>, Sets output file.
--output <output> If missing, 'a.out' is used by default.
If '-' is passed, output to stdount.
-h, --help Show this help message and exit.]], parser:get_help())
end)
it("handles description with less lines than usage", function()
local parser = Parser "foo"
parser:option "-o --output"
:description "Sets output file."
assert.equal([[
Usage: foo [-o <output>] [-h]
Options:
-o <output>, Sets output file.
--output <output>
-h, --help Show this help message and exit.]], parser:get_help())
end)
it("shows default values", function()
local parser = Parser "foo"
parser:option "-o"