mirror of
https://github.com/TangentFoxy/argparse.git
synced 2026-03-14 12:46:50 -06:00
Return :error() method
This commit is contained in:
+10
-8
@@ -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