diff options
| author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-05 16:26:12 +0200 |
|---|---|---|
| committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-05 16:43:04 +0200 |
| commit | 4c96efa86e18cc836eb635c9dc61c0cf9eff8468 (patch) | |
| tree | 221182ada0a31f209db9cbff77742b58723dc982 /lib/utils/parse_options.c | |
| parent | 3f5c913bb2c534705b883edb813e36d5c72768da (diff) | |
add OPT_GROUP option
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Diffstat (limited to 'lib/utils/parse_options.c')
| -rw-r--r-- | lib/utils/parse_options.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/utils/parse_options.c b/lib/utils/parse_options.c index 97454e1a..e65a1bb9 100644 --- a/lib/utils/parse_options.c +++ b/lib/utils/parse_options.c @@ -22,13 +22,22 @@ void parse_usage_and_die(const char * const * usage, const struct options *opt) while (*usage && **usage) fprintf(stderr, _(" or: %s\n"), *usage++); - fputc('\n', stderr); + if (opt->type != OPTION_GROUP) + fputc('\n', stderr); for (; opt->type != OPTION_END; opt++) { size_t pos; int pad; + if (opt->type == OPTION_GROUP) + { + fputc('\n', stderr); + if (*opt->help) + fprintf(stderr, "%s\n", opt->help); + continue; + } + pos = fprintf(stderr, " "); if (opt->short_name) pos += fprintf(stderr, "-%c", opt->short_name); @@ -81,6 +90,7 @@ void 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_GROUP: case OPTION_END: break; } @@ -125,6 +135,7 @@ void parse_opts(int argc, char **argv, const struct options *opt, if (optarg) *(char**)opt[ii].value = (char*)optarg; break; + case OPTION_GROUP: case OPTION_END: break; } |
