*Updated. The old version is depreciated, and will soon be removed.
MORE PLANNED UPDATES:
- Add substitution of a table of arg sets for the number of args.
- Test function for itable reversion
- Add more itable management functions
pastebin get PSFnwfPp getOpts
Example Program
APIS:
[object parserObject] :add(aliases, fullname, help, runFunc, maxArgs or nil, usage) --runFunc is a function with args [args [, [object parserObject]]] :addM([same args as :add]) --Same as add, but creates mandatory args :setHeader(head) --Creates the help header .opts --a table with more tables, stores flag info .functions --Only available in flags .escape(escapepoint) --Escaping. If a number is provided, anything >= that number will be escaped. If a table is provided, those specific arguments are escaped. .toITable() --Removes gaps from tables .getFlagPos() --Untested, returns pos of current flag loadfile('getOpts', _G)() .getArgs(string) returns table --A tokeniser .toITable(table) --removes gaps from table .help(struct.opts, struct.header) --Prints help screen .parse(struct, args) returns table --Returns left over args, this is the main function .newStruct(autoGenItems) returns [object parserObject]
What has changed?
- Items can now be called multiple times
- New functions
- Reversed args for the function used for :add func argument, now args, parser instead of parser, args
- Now run in chronological order
- You can figure out which numbered item from the original table args were. The indices on the argument tables contain gaps.
- Added anon functions. The -% flag is now an anon function and is no longer hard-coded in
- added usage arg to :add
Initializing a struct without the autoGenItems flag will not contain help and -%. Re-initializing the parser.opts table will also remove these.
Old post
Edited by EveryOS, 19 December 2017 - 03:05 PM.