summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bebdd27)
raw | patch | inline | side by side (parent: bebdd27)
author | Christian Couder <chriscool@tuxfamily.org> | |
Mon, 2 Feb 2009 05:12:58 +0000 (06:12 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 1 Jun 2009 00:03:40 +0000 (17:03 -0700) |
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>
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>
builtin-replace.c | patch | blob | history | |
parse-options.c | patch | blob | history | |
parse-options.h | patch | blob | history |
diff --git a/builtin-replace.c b/builtin-replace.c
index e3767b9661f20660498add7b7fcd8928094a36d6..8220d6eb38c8027d50a3980e669fba0f1851c658 100644 (file)
--- a/builtin-replace.c
+++ b/builtin-replace.c
OPT_END()
};
- argc = parse_options(argc, argv, options, git_replace_usage, 0);
+ argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
if (list && delete)
usage_with_options(git_replace_usage, options);
diff --git a/parse-options.c b/parse-options.c
index b85cab2466244ec3c8ea97dc0882c2971e7b8061..743f5bae4e11346d37038faba08219275addc334 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
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)
{
diff --git a/parse-options.h b/parse-options.h
index b374ade95c382afd742a32c80338e32cc565cab2..f0f885c67de0905d80e414ce3c4b0aa83d3c813c 100644 (file)
--- a/parse-options.h
+++ b/parse-options.h
extern NORETURN void usage_with_options(const char * const *usagestr,
const struct option *options);
+extern NORETURN void usage_msg_opt(const char *msg,
+ const char * const *usagestr,
+ const struct option *options);
+
/*----- incremental advanced APIs -----*/
enum {