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

@@ -116,6 +116,42 @@ Usage: foo <first> <second-and-third> <second-and-third>
)
end)
it("omits usage for hidden arguments and options", function()
local parser = Parser "foo"
:add_help(false)
parser:flag "-d" "--deprecated"
:hidden(true)
parser:flag "-n" "--not-deprecated"
parser:argument "normal"
parser:argument "deprecated"
:args "?"
:hidden(true)
assert.equal(
[=[Usage: foo [-n] <normal>]=],
parser:get_usage()
)
end)
it("omits usage for mutexes if all elements are hidden", function()
local parser = Parser "foo"
:add_help(false)
parser:mutex(
parser:flag "--misfeature"
:hidden(true),
parser:flag "--no-misfeature"
:action "store_false"
:target "misfeature"
:hidden(true)
)
parser:flag "--feature"
assert.equal(
[=[Usage: foo [--feature]]=],
parser:get_usage()
)
end)
it("usage messages for commands are correct after several invocations", function()
local parser = Parser "foo"
:add_help(false)