Added help message generation; Improved optional arguments handling.

This commit is contained in:
mpeterv
2014-01-26 15:20:42 +04:00
parent d279429896
commit 404ec5213a
5 changed files with 116 additions and 3 deletions

View File

@@ -15,6 +15,14 @@ describe("tests related to positional arguments", function()
assert.same({foo = "bar"}, args)
end)
it("handles optional argument correctly", function()
local parser = argparse.parser()
parser:argument "foo"
:args "?"
local args = parser:parse({"bar"})
assert.same({foo = "bar"}, args)
end)
it("handles several arguments correctly", function()
local parser = argparse.parser()
parser:argument "foo1"
@@ -86,6 +94,7 @@ describe("tests related to positional arguments", function()
it("handles sudden option correctly", function()
local parser = argparse.parser()
:add_help(false)
parser:argument "foo"
assert.has_error(function() parser:parse{"-q"} end, "unknown option '-q'")