mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
Support --
as an option
This commit is contained in:
@@ -136,6 +136,16 @@ describe("tests related to options", function()
|
|||||||
assert.same({input = {"bar", "-f", "--foo" , "bar"}}, args)
|
assert.same({input = {"bar", "-f", "--foo" , "bar"}}, args)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("allows using -- as an option", function()
|
||||||
|
local parser = Parser()
|
||||||
|
parser:flag "--unrelated"
|
||||||
|
parser:option "--"
|
||||||
|
:args "*"
|
||||||
|
:target "tail"
|
||||||
|
local args = parser:parse{"--", "foo", "--unrelated", "bar"}
|
||||||
|
assert.same({tail = {"foo", "--unrelated", "bar"}}, args)
|
||||||
|
end)
|
||||||
|
|
||||||
describe("Special chars set", function()
|
describe("Special chars set", function()
|
||||||
it("handles windows-style options", function()
|
it("handles windows-style options", function()
|
||||||
local parser = Parser()
|
local parser = Parser()
|
||||||
|
@@ -1169,7 +1169,13 @@ function ParseState:parse(args)
|
|||||||
|
|
||||||
if arg:sub(2, 2) == first then
|
if arg:sub(2, 2) == first then
|
||||||
if #arg == 2 then
|
if #arg == 2 then
|
||||||
self:close()
|
if self.options[arg] then
|
||||||
|
local option = self:get_option(arg)
|
||||||
|
self:invoke(option, arg)
|
||||||
|
else
|
||||||
|
self:close()
|
||||||
|
end
|
||||||
|
|
||||||
self.handle_options = false
|
self.handle_options = false
|
||||||
else
|
else
|
||||||
local equals = arg:find "="
|
local equals = arg:find "="
|
||||||
|
Reference in New Issue
Block a user