mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-30 03:52:19 +00:00
Change error messages for missing elements
* For arguments: "argument 'foo' is required" -> "missing argument 'foo'" * For options: "option '--foo' must be used at least 1 time" -> "missing option '--foo'"
This commit is contained in:
@@ -809,7 +809,7 @@ function ElementState:close()
|
||||
else
|
||||
if #self.args == 0 then
|
||||
if getmetatable(self.element) == Argument then
|
||||
self:error("%s is required", self.name)
|
||||
self:error("missing %s", self.name)
|
||||
elseif self.element._maxargs == 1 then
|
||||
self:error("%s requires an argument", self.name)
|
||||
end
|
||||
@@ -996,6 +996,8 @@ function ParseState:finalize()
|
||||
option:invoke(name)
|
||||
option:close()
|
||||
end
|
||||
elseif option.invocations == 0 then
|
||||
self:error("missing %s", name)
|
||||
else
|
||||
self:error("%s must be used %s", name, bound("time", mincount, option.element._maxcount))
|
||||
end
|
||||
|
Reference in New Issue
Block a user