diff --git a/README.md b/README.md index 58e7f2d..9ea21be 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/argparse.lua b/src/argparse.lua index 59f34dd..f45e68f 100644 --- a/src/argparse.lua +++ b/src/argparse.lua @@ -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(...)