From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, carlos.duclos@nokia.com,
Pierre Habouzit <madcoder@madism.org>
Subject: [PATCH 5/4] parseopt: document KEEP_ARGV0, KEEP_UNKNOWN, NO_INTERNAL_HELP
Date: Mon, 09 Mar 2009 21:26:56 +0100 [thread overview]
Message-ID: <49B57B90.4060409@lsrfire.ath.cx> (raw)
In-Reply-To: <7vvdqjkbka.fsf@gitster.siamese.dyndns.org>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
Documentation/technical/api-parse-options.txt | 27 +++++++++++++++++++++++++
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..dc72987 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:
`PARSE_OPT_KEEP_DASHDASH`::
@@ -77,6 +83,27 @@ Flags are the bitwise-or of:
Using this flag, processing is stopped at the first non-option
argument.
+`PARSE_OPT_KEEP_ARGV0`::
+ Keep the first argument, which contains the program name. It's
+ removed from argv[] by default.
+
+`PARSE_OPT_KEEP_UNKNOWN`::
+ 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.
+
+`PARSE_OPT_NO_INTERNAL_HELP`::
+ 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
--------------
--
1.6.2
next prev parent reply other threads:[~2009-03-09 20:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-05 10:07 What's in git.git (Mar 2009, #02; Thu, 05) Junio C Hamano
2009-03-07 19:14 ` René Scharfe
2009-03-08 18:12 ` [PATCH 1/4] parseopt: add PARSE_OPT_KEEP_UNKNOWN René Scharfe
2009-03-08 20:24 ` Junio C Hamano
2009-03-08 20:30 ` Junio C Hamano
2009-03-09 20:26 ` René Scharfe [this message]
2009-03-09 20:57 ` [PATCH 6/4] parseopt: prevent KEEP_UNKNOWN and STOP_AT_NON_OPTION from being used together René Scharfe
2009-03-08 18:15 ` [PATCH 2/4] parseopt: add PARSE_OPT_NO_INTERNAL_HELP René Scharfe
2009-03-08 18:16 ` [PATCH 3/4] parseopt: make usage optional René Scharfe
2009-03-08 20:25 ` Junio C Hamano
2009-03-09 20:19 ` René Scharfe
2009-03-08 18:21 ` [PATCH 4/4] archive: use parseopt for local-only options René Scharfe
2009-03-08 20:20 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49B57B90.4060409@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=carlos.duclos@nokia.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@madism.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).