olua.lib.Object└─ olua.app.ArgumentParser
I understand both short and long options, with any number of arguments (although your users may get confused if you use more than one). With a short option, I will automatically detect whether the argument is separated with a space or not.
I don't handle combined short options (ls -lR), or using = to separate
the option from the argument.
To use me, instantiate me and then call one of the addOption: methods
to add option handlers. When ready, call parse: with a preparsed command
line. I will then call the handlers from left to right. Each handler
should return the number of arguments consumed; typically 0 or 1.
parse: will return a list of leftover command line arguments.
Unrecognised options are handled by throwing
olua.app.UnrecognisedOptionException.
You usually don't need to instantiate me directly; olua.app.Application
will do it for you.
| Method Summary |
|---|
|
| Method Detail |
|---|
addOption: option withHandler: handlerAdds a handler to the parser.
option - the option (e.g. "x" or "extra")handler - the handleraddOptions: optionsAdds a table of handlers to the parser.
options - the option table (e.g. {x = function()...end})addOptions: options withHandler: handlerAdds several options with the same handler.
option - an array of options (e.g. {"x", "extra"})handler - the handlerparse: argsParses a set of command line options.
The options are processed left to right. All option handlers are
executed. The unprocessed arguments are returned. Unrecognised options
are handled by throwing olua.lib.UnrecognisedOptionError.