mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 11:02:20 +00:00
minor refactoring
This commit is contained in:
@@ -13,7 +13,7 @@ Features:
|
||||
* Combined short options(e.g. `-zx`);
|
||||
* Short options combined with arguments(e.g. `-I/usr/local/include`);
|
||||
* Long options(e.g. `--quiet`);
|
||||
* Long options with arguments(e.g. `--from there);
|
||||
* Long options with arguments(e.g. `--from there`);
|
||||
* GNU-style long options with arguments(e.g. `--from=there`).
|
||||
* Supports named arguments consuming several arguments.
|
||||
* Supports options and flags which can be invoked several times, consuming several arguments.
|
||||
|
@@ -40,13 +40,15 @@ local Parser = class {
|
||||
options = {},
|
||||
commands = {},
|
||||
require_command = false,
|
||||
fields = {"name", "description", "target", "require_command"}
|
||||
fields = {
|
||||
"name", "description", "target", "require_command"
|
||||
}
|
||||
}:include(Declarative)
|
||||
|
||||
local Command = Parser:extends {
|
||||
__name = "Command",
|
||||
aliases = {}
|
||||
}:include(Declarative)
|
||||
}
|
||||
|
||||
local Argument = class {
|
||||
__name = "Argument",
|
||||
@@ -58,10 +60,9 @@ local Argument = class {
|
||||
}
|
||||
}:include(Declarative)
|
||||
|
||||
local Option = class {
|
||||
local Option = Argument:extends {
|
||||
__name = "Option",
|
||||
aliases = {},
|
||||
args = 1,
|
||||
count = "?",
|
||||
overwrite = true,
|
||||
fields = {
|
||||
@@ -70,12 +71,12 @@ local Option = class {
|
||||
"mincount", "maxcount", "default", "convert",
|
||||
"overwrite"
|
||||
}
|
||||
}:include(Declarative)
|
||||
}
|
||||
|
||||
local Flag = Option:extends {
|
||||
__name = "Flag",
|
||||
args = 0
|
||||
}:include(Declarative)
|
||||
}
|
||||
|
||||
function Parser:argument(...)
|
||||
local argument = Argument:new(...)
|
||||
|
Reference in New Issue
Block a user