Replace - with _ in default target

This commit is contained in:
mpeterv
2014-08-23 11:35:49 +04:00
parent b8766c8cdf
commit 6e02b89b9b
2 changed files with 8 additions and 1 deletions

View File

@@ -17,6 +17,13 @@ describe("tests related to options", function()
assert.same({server = "foo"}, args) assert.same({server = "foo"}, args)
end) end)
it("normalizes default target", function()
local parser = Parser()
parser:option("--from-server")
local args = parser:parse({"--from-server", "foo"})
assert.same({from_server = "foo"}, args)
end)
it("handles non-standard charset", function() it("handles non-standard charset", function()
local parser = Parser() local parser = Parser()
parser:option "/s" parser:option "/s"

View File

@@ -783,7 +783,7 @@ function Parser:_parse(args, errhandler)
end end
local type_ = option:_get_type() local type_ = option:_get_type()
targets[option] = option:_get_target() targets[option] = option:_get_target():gsub("-", "_")
if type_ == "counter" then if type_ == "counter" then
result[targets[option]] = 0 result[targets[option]] = 0