cctools
|
Pull command line args from a JSON document. More...
Go to the source code of this file.
Functions | |
void | jx_getopt_push (struct jx *j) |
Process command lines from a JX document. More... | |
int | jx_getopt (int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) |
Parse the next argument. More... | |
Pull command line args from a JSON document.
This is a wrapper around getopt_long that supports reading arguments from a JX object during command line parsing. The object's keys are interpreted as long option names, and the values are stored in optarg. Currently only string, integer, float, and boolean values are written to optarg. Other value types result in optarg being set to NULL. To access the raw JX struture provided as an option argument, callers can inspect jx_optarg. JX-aware programs can check jx_optarg when reading JX values from the command line to simplify parsing and avoid quoting issues.
void jx_getopt_push | ( | struct jx * | j | ) |
Process command lines from a JX document.
The pushed args will be processesed next, before any remaining command line args or previously pushed JX args.
j | The args to process. |
int jx_getopt | ( | int | argc, |
char *const | argv[], | ||
const char * | optstring, | ||
const struct option * | longopts, | ||
int * | longindex | ||
) |
Parse the next argument.
If there are no JX args to be processed, this is the same as calling getopt_long() directly.