mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Removed :usage() hooks for arguments and options
This commit is contained in:
@@ -131,18 +131,6 @@ describe("tests related to usage message generation", function()
|
|||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("uses per-option message provided by user", function()
|
|
||||||
local parser = Parser "foo"
|
|
||||||
:add_help(false)
|
|
||||||
parser:flag "-q" "--quiet"
|
|
||||||
:usage "[-q | --quiet]"
|
|
||||||
|
|
||||||
assert.equal(
|
|
||||||
[=[Usage: foo [-q | --quiet]]=],
|
|
||||||
parser:get_usage()
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
|
|
||||||
it("uses argnames provided by user", function()
|
it("uses argnames provided by user", function()
|
||||||
local parser = Parser "foo"
|
local parser = Parser "foo"
|
||||||
:add_help(false)
|
:add_help(false)
|
||||||
|
@@ -170,7 +170,6 @@ do -- Create classes with setters
|
|||||||
default = typecheck.string "default",
|
default = typecheck.string "default",
|
||||||
defmode = typecheck.string "defmode",
|
defmode = typecheck.string "defmode",
|
||||||
convert = convert,
|
convert = convert,
|
||||||
usage = typecheck.string "usage",
|
|
||||||
argname = typecheck.string "argname"
|
argname = typecheck.string "argname"
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -191,7 +190,6 @@ do -- Create classes with setters
|
|||||||
convert = convert,
|
convert = convert,
|
||||||
overwrite = typecheck.boolean "overwrite",
|
overwrite = typecheck.boolean "overwrite",
|
||||||
action = typecheck["function"] "action",
|
action = typecheck["function"] "action",
|
||||||
usage = typecheck.string "usage",
|
|
||||||
argname = typecheck.string "argname"
|
argname = typecheck.string "argname"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -229,10 +227,6 @@ function Argument:_get_arg_usage(argname)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Argument:_get_usage()
|
function Argument:_get_usage()
|
||||||
if self._usage then
|
|
||||||
return self._usage
|
|
||||||
end
|
|
||||||
|
|
||||||
local usage = table.concat(self:_get_arg_usage("<" .. self._name .. ">"), " ")
|
local usage = table.concat(self:_get_arg_usage("<" .. self._name .. ">"), " ")
|
||||||
|
|
||||||
if self._default and self._defmode:find "u" then
|
if self._default and self._defmode:find "u" then
|
||||||
@@ -265,10 +259,6 @@ function Argument:_get_type()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Option:_get_usage()
|
function Option:_get_usage()
|
||||||
if self._usage then
|
|
||||||
return self._usage
|
|
||||||
end
|
|
||||||
|
|
||||||
local usage = self:_get_arg_usage("<" .. self:_get_target() .. ">")
|
local usage = self:_get_arg_usage("<" .. self:_get_target() .. ">")
|
||||||
table.insert(usage, 1, self._name)
|
table.insert(usage, 1, self._name)
|
||||||
usage = table.concat(usage, " ")
|
usage = table.concat(usage, " ")
|
||||||
|
Reference in New Issue
Block a user