@@ -66,6 +66,12 @@ Steps to parse options
6666non-option arguments in `argv[]`.
6767`argc` is updated appropriately because of the assignment.
6868+
69+ You can also pass NULL instead of a usage array as fourth parameter of
70+ parse_options(), to avoid displaying a help screen with usage info and
71+ option list. This should only be done if necessary, e.g. to implement
72+ a limited parser for only a subset of the options that needs to be run
73+ before the full parser, which in turn shows the full help message.
74+ +
6975Flags are the bitwise-or of:
7076
7177`PARSE_OPT_KEEP_DASHDASH`::
@@ -77,6 +83,27 @@ Flags are the bitwise-or of:
7783 Using this flag, processing is stopped at the first non-option
7884 argument.
7985
86+ `PARSE_OPT_KEEP_ARGV0`::
87+ Keep the first argument, which contains the program name. It's
88+ removed from argv[] by default.
89+
90+ `PARSE_OPT_KEEP_UNKNOWN`::
91+ Keep unknown arguments instead of erroring out. This doesn't
92+ work for all combinations of arguments as users might expect
93+ it to do. E.g. if the first argument in `--unknown --known`
94+ takes a value (which we can't know), the second one is
95+ mistakenly interpreted as a known option. Similarly, if
96+ `PARSE_OPT_STOP_AT_NON_OPTION` is set, the second argument in
97+ `--unknown value` will be mistakenly interpreted as a
98+ non-option, not as a value belonging to the unknown option,
99+ stopping the parser early.
100+
101+ `PARSE_OPT_NO_INTERNAL_HELP`::
102+ By default, parse_options() handles `-h`, `--help` and
103+ `--help-all` internally, by showing a help screen. This option
104+ turns it off and allows one to add custom handlers for these
105+ options, or to just leave them unknown.
106+
80107Data Structure
81108--------------
82109
0 commit comments