Add handle_options property to Parser

When `parser:handle_options(true)` (the default), the parser will behave as
before.

When `parser:handle_options(false)`, all options will be passed verbatim
to the argument list, as if the input included double-hyphens.
This commit is contained in:
Kyle McLamb
2015-06-17 03:41:36 -04:00
parent 85809c8ad4
commit 0fedcdeade
2 changed files with 17 additions and 2 deletions

View File

@@ -125,6 +125,17 @@ describe("tests related to options", function()
assert.same({input = "foo", exclude = {}}, args)
end)
it("does not interpret options if disabled", function()
local parser = Parser()
parser:handle_options(false)
parser:argument "input"
:args "*"
parser:option "-f" "--foo"
:args "*"
local args = parser:parse{"bar", "-f", "--foo" , "bar"}
assert.same({input = {"bar", "-f", "--foo" , "bar"}}, args)
end)
describe("Special chars set", function()
it("handles windows-style options", function()
local parser = Parser()