mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
Return :error() method
This commit is contained in:
@@ -760,15 +760,17 @@ function Parser:_parse(args, errhandler)
|
||||
return result
|
||||
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)
|
||||
return self:_parse(args, function(parser, msg)
|
||||
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)
|
||||
return self:_parse(args, Parser.error)
|
||||
end
|
||||
|
||||
function Parser:pparse(args)
|
||||
|
Reference in New Issue
Block a user