CommandParser
Inherits Reference < Object
The command parser is used to parse a command with parameters as follows:
- All arguments are separated by spaces
- Command can start with non-named arguments (positional) separated by spaces
- First named argument means no more positional args
- Names args are always K=V without spaces
- Arguments can be quoted within '' or ""
- Arguments can be arrays of values, within square brackets and separated by spaces.
- No interpolation of values (for now?)
Constructors
new(query)
SourceInstance methods
arg_named(name)
Get the value of a named argument, raising exception if no such named argument
arg_named?(name, default = nil)
Get the value of a named argument, return specified default value or nil if no such named argument
expect?(*args, **params)
Use this to see if the command matches expected arguments and parameters, where
values can be String (exact match), array of String (match one), Class expressions (type match), or
any other "subsumption operator" matches (i.e. ===) include Regex expression.
Example: `cmd.expect "/cmd", String, type: String?
input
Source