mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-29 03:22:18 +00:00
Add hidden command and option aliases
Also auto-add an alias with dashes in place of underscores if an alias has an underscore.
This commit is contained in:
@@ -57,14 +57,14 @@ describe("tests related to options", function()
|
||||
assert.same({server = {"foo", "bar"}}, args)
|
||||
end)
|
||||
|
||||
it("handles short option correclty", function()
|
||||
it("handles short option correctly", function()
|
||||
local parser = Parser()
|
||||
parser:option "-s" "--server"
|
||||
local args = parser:parse({"-s", "foo"})
|
||||
assert.same({server = "foo"}, args)
|
||||
end)
|
||||
|
||||
it("handles flag correclty", function()
|
||||
it("handles flag correctly", function()
|
||||
local parser = Parser()
|
||||
parser:flag "-q" "--quiet"
|
||||
local args = parser:parse({"--quiet"})
|
||||
@@ -73,7 +73,7 @@ describe("tests related to options", function()
|
||||
assert.same({}, args)
|
||||
end)
|
||||
|
||||
it("handles combined flags correclty", function()
|
||||
it("handles combined flags correctly", function()
|
||||
local parser = Parser()
|
||||
parser:flag "-q" "--quiet"
|
||||
parser:flag "-f" "--fast"
|
||||
@@ -88,7 +88,7 @@ describe("tests related to options", function()
|
||||
assert.same({server = "foo"}, args)
|
||||
end)
|
||||
|
||||
it("handles flags combined with short option correclty", function()
|
||||
it("handles flags combined with short option correctly", function()
|
||||
local parser = Parser()
|
||||
parser:flag "-q" "--quiet"
|
||||
parser:option "-s" "--server"
|
||||
@@ -146,6 +146,14 @@ describe("tests related to options", function()
|
||||
assert.same({tail = {"foo", "--unrelated", "bar"}}, args)
|
||||
end)
|
||||
|
||||
it("handles hidden option aliases", function()
|
||||
local parser = Parser()
|
||||
parser:option "--server"
|
||||
:hidden_name "--from"
|
||||
local args = parser:parse{"--from", "foo"}
|
||||
assert.same({server = "foo"}, args)
|
||||
end)
|
||||
|
||||
describe("Special chars set", function()
|
||||
it("handles windows-style options", function()
|
||||
local parser = Parser()
|
||||
|
Reference in New Issue
Block a user