Class Command
Command class
Methods
Command:action (fn) | Add action function to Command |
Command:argument (argname, description, default) | Add a argument description |
Command:has_option (option) | Find a option for the command |
Command:names () | Returns a table with command name and alias |
Command:option (long, short[, description=""[, transform[, type_opt="normal"[, default=nil]]]]) | Add a flag option |
Command:set_alias (alias) | Set alias for the command |
Methods
- Command:action (fn)
-
Add action function to Command
Parameters:
- fn function Set action function for command.
Returns:
Usage:
cmd:action( function(parsed, command, lummander) -- command logic -- parse is Parsed -- command is command itself -- lummander is lummander instance print("Hello from command") end)
- Command:argument (argname, description, default)
-
Add a argument description
Parameters:
- argname string argument name.
- description string to set in the argument.
- default string to set in the argument.
Returns:
- Command:has_option (option)
-
Find a option for the command
Parameters:
- option string string including - or --
Returns:
-
Option
- Command:names ()
-
Returns a table with command name and alias
Returns:
- Command:option (long, short[, description=""[, transform[, type_opt="normal"[, default=nil]]]])
-
Add a flag option
Parameters:
- long string Long flag will be prefixed by "--".
- short string Short flag will be prefixed by "-".
- description string Flag option description. (default "")
- transform function Transform paramameter before execute Command action. (optional)
- type_opt string Type flag (normal or flag). (default "normal")
- default string Default value. (default nil)
Returns:
Usage:
cmd:option("optname", "o", "Option description", function(value) return ">" .. value .. "<" end, "normal", "option_default_value") -- or cmd:option({ long = "optname", short = "o", description = "Option description", transform = function(value) return ">" .. value .. "<" end, type = "normal", default = "option_default_value" }) -- you can add multiple options cmd:option("opt1",...) :option("opt2",...)
- Command:set_alias (alias)
-
Set alias for the command
Parameters:
Returns: