mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Add argument choices
This commit is contained in:
@@ -290,6 +290,16 @@ describe("tests related to options", function()
|
||||
end, "too many arguments")
|
||||
end)
|
||||
|
||||
it("handles invalid argument choices correctly", function()
|
||||
local parse = Parser()
|
||||
parse:option "-s" "--server" {
|
||||
choices = {"foo", "bar", "baz"}
|
||||
}
|
||||
assert.has_error(function()
|
||||
parse:parse{"-slocalhost"}
|
||||
end, "argument for option '-s' must be one of 'foo', 'bar', 'baz'")
|
||||
end)
|
||||
|
||||
it("doesn't accept GNU-like long options when it doesn't need arguments", function()
|
||||
local parser = Parser()
|
||||
parser:flag "-q" "--quiet"
|
||||
|
Reference in New Issue
Block a user