Add hidden property, unlisting elements from usage and help

This commit is contained in:
Peter Melnichenko
2018-04-07 22:09:18 +03:00
parent 3edbd19b3d
commit 4f72bfeb8e
3 changed files with 88 additions and 5 deletions

View File

@@ -182,4 +182,46 @@ Options:
assert.equal([[
I don't like your format of help messages]], parser:get_help())
end)
it("does not mention hidden arguments, options, and commands", function()
local parser = Parser "foo"
parser:argument "normal"
parser:argument "deprecated"
:args "?"
:hidden(true)
parser:flag "--feature"
parser:flag "--misfeature"
:hidden(true)
parser:command "good"
parser:command "okay"
parser:command "never-use-this-one"
:hidden(true)
assert.equal([[
Usage: foo [--feature] [-h] <normal> <command> ...
Arguments:
normal
Options:
--feature
-h, --help Show this help message and exit.
Commands:
good
okay]], parser:get_help())
end)
it("omits categories if all elements are hidden", function()
local parser = Parser "foo"
:add_help(false)
parser:argument "deprecated"
:args "?"
:hidden(true)
parser:flag "--misfeature"
:hidden(true)
assert.equal([[
Usage: foo]], parser:get_help())
end)
end)