Options Parser is used to parse options provided to command-line programs.
e.g. to parse a version flag and an output argument:
# set up an options parser options := options_parser_new() options.title(options, "testproc: a fancy CLI program") options_add(options, ["-v", "--version"], "", "show version") options_add(options, ["-o", "--output"] , "filename", "set output filename") # parse some input, e.g. arglist could be arguments passed to main options_parse(options, arglist) if options_has(options, "-v") then write_version() if options_has(options, "-h") then write_help(options) if options_has(options, "-o") then output_file := options_value(options, "-o")
Note that `options_has` and `options_value` always use the first of the two options as their key, irrespective of the option used by the caller.
options_add (object, forms, value, help_string)
Adds a new option definition to current options object.
Parameters:
options_arguments (object)
Returns the remaining elements of the parsed string, after any options.
Parameters:
options_has (object, form)
Succeeds if form was used in parsed input.
Parameters:
options_parse (object, arglist)
Parses the given list of input arguments.
Parameters:
options_parser_new ()
Returns a new record ready to store option definitions.
options_title (object, title)
Adds a title string to the current options object.
Parameters:
options_value (object, form)
Returns value of form from parsed input, or fails if form not found.
Parameters:
options_write_help (object)
Writes the help message.
Parameters: