mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-30 03:52:19 +00:00
more command tests, added require_command
This commit is contained in:
@@ -39,7 +39,8 @@ local Parser = class {
|
||||
arguments = {},
|
||||
options = {},
|
||||
commands = {},
|
||||
fields = {"name", "description", "target"}
|
||||
require_command = false,
|
||||
fields = {"name", "description", "target", "require_command"}
|
||||
}:include(Declarative)
|
||||
|
||||
local Command = Parser:extends {
|
||||
@@ -448,6 +449,10 @@ function Parser:parse(args)
|
||||
close(cur_arg)
|
||||
end
|
||||
|
||||
if parser.require_command and #commands > 0 then
|
||||
parser:error("command is required")
|
||||
end
|
||||
|
||||
format()
|
||||
|
||||
return result
|
||||
|
Reference in New Issue
Block a user