Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2009-02-02 08:12:58 +0300
committerJunio C Hamano <gitster@pobox.com>2009-06-01 04:03:40 +0400
commit451bb210f81c10b60bf90403c9183be26beaaabf (patch)
tree7f65acf1d82dac05446baea45684349cfaa3874a /parse-options.c
parentbebdd271ff660d603ad75fef346ad1ff19fca0cb (diff)
parse-options: add new function "usage_msg_opt"
This function can be used instead of "usage_with_options" when you want to print an error message before the usage string. It may be useful because: if (condition) usage_msg_opt("condition is false", usage, opts); is shorter than: if (condition) { fprintf(stderr, "condition is false\n\n"); usage_with_options(usage, opts); } and may be more consistent. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c
index b85cab2466..743f5bae4e 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -555,6 +555,14 @@ void usage_with_options(const char * const *usagestr,
exit(129);
}
+void usage_msg_opt(const char *msg,
+ const char * const *usagestr,
+ const struct option *options)
+{
+ fprintf(stderr, "%s\n\n", msg);
+ usage_with_options(usagestr, options);
+}
+
int parse_options_usage(const char * const *usagestr,
const struct option *opts)
{