path: root/Documentation/technical/api-parse-options.txt
diff options
authorRené Scharfe <>2009-03-09 20:26:56 (GMT)
committerJunio C Hamano <>2009-03-09 22:24:16 (GMT)
commit9ad7e6ea24739c298d0a9660121de6df0502915a (patch)
tree2e7475c14656279e0c350c03636ea6ef1068791b /Documentation/technical/api-parse-options.txt
parent52e7787609d18af76a8c1befb0a06123fb7ce89e (diff)
Signed-off-by: Rene Scharfe <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'Documentation/technical/api-parse-options.txt')
1 files changed, 27 insertions, 0 deletions
diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt
index 539863b..20b44ff 100644
--- a/Documentation/technical/api-parse-options.txt
+++ b/Documentation/technical/api-parse-options.txt
@@ -66,6 +66,12 @@ Steps to parse options
non-option arguments in `argv[]`.
`argc` is updated appropriately because of the assignment.
+You can also pass NULL instead of a usage array as fourth parameter of
+parse_options(), to avoid displaying a help screen with usage info and
+option list. This should only be done if necessary, e.g. to implement
+a limited parser for only a subset of the options that needs to be run
+before the full parser, which in turn shows the full help message.
Flags are the bitwise-or of:
@@ -77,6 +83,27 @@ Flags are the bitwise-or of:
Using this flag, processing is stopped at the first non-option
+ Keep the first argument, which contains the program name. It's
+ removed from argv[] by default.
+ Keep unknown arguments instead of erroring out. This doesn't
+ work for all combinations of arguments as users might expect
+ it to do. E.g. if the first argument in `--unknown --known`
+ takes a value (which we can't know), the second one is
+ mistakenly interpreted as a known option. Similarly, if
+ `PARSE_OPT_STOP_AT_NON_OPTION` is set, the second argument in
+ `--unknown value` will be mistakenly interpreted as a
+ non-option, not as a value belonging to the unknown option,
+ stopping the parser early.
+ By default, parse_options() handles `-h`, `--help` and
+ `--help-all` internally, by showing a help screen. This option
+ turns it off and allows one to add custom handlers for these
+ options, or to just leave them unknown.
Data Structure