summaryrefslogtreecommitdiffstats
path: root/lib/utils/parse_options.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-11-02 12:38:30 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-11-02 12:38:30 +0100
commit3c8781e79c38961c47fc0683a4eaf665b835153c (patch)
tree234611d66be82ace3fe7276dd162d07593294bcd /lib/utils/parse_options.c
parent8864e7d8ab05b59372f55ec8d637296aefa1515e (diff)
abrt-handle-crashdump: add -l[pfx] option to list possible events
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'lib/utils/parse_options.c')
-rw-r--r--lib/utils/parse_options.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/utils/parse_options.c b/lib/utils/parse_options.c
index 7029643f..c1a2c297 100644
--- a/lib/utils/parse_options.c
+++ b/lib/utils/parse_options.c
@@ -37,7 +37,12 @@ void parse_usage_and_die(const char *usage, const struct options *opt)
pos += fprintf(stderr, "--%s", opt->long_name);
if (opt->argh)
- pos += fprintf(stderr, " %s", opt->argh);
+ {
+ const char *fmt = " %s";
+ if (opt->type == OPTION_OPTSTRING)
+ fmt = "[%s]";
+ pos += fprintf(stderr, fmt, opt->argh);
+ }
if (pos <= USAGE_OPTS_WIDTH)
pad = USAGE_OPTS_WIDTH - pos;
@@ -91,6 +96,11 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt,
if (opt[ii].short_name)
strbuf_append_strf(shortopts, "%c:", opt[ii].short_name);
break;
+ case OPTION_OPTSTRING:
+ curopt->has_arg = optional_argument;
+ if (opt[ii].short_name)
+ strbuf_append_strf(shortopts, "%c::", opt[ii].short_name);
+ break;
case OPTION_GROUP:
case OPTION_END:
break;
@@ -153,6 +163,7 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt,
*(int*)opt[ii].value = xatoi(optarg);
break;
case OPTION_STRING:
+ case OPTION_OPTSTRING:
if (optarg)
*(char**)opt[ii].value = (char*)optarg;
break;