mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
Return :error() method
This commit is contained in:
@@ -760,15 +760,17 @@ function Parser:_parse(args, errhandler)
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Parser:error(msg)
|
||||||
|
if _TEST then
|
||||||
|
error(msg)
|
||||||
|
else
|
||||||
|
io.stderr:write(("%s\r\n\r\nError: %s\r\n"):format(self:get_usage(), msg))
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Parser:parse(args)
|
function Parser:parse(args)
|
||||||
return self:_parse(args, function(parser, msg)
|
return self:_parse(args, Parser.error)
|
||||||
if _TEST then
|
|
||||||
error(msg)
|
|
||||||
else
|
|
||||||
io.stderr:write(("%s\r\n\r\nError: %s\r\n"):format(parser:get_usage(), msg))
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser:pparse(args)
|
function Parser:pparse(args)
|
||||||
|
Reference in New Issue
Block a user