diff options
| author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-05 11:22:58 +0200 |
|---|---|---|
| committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-05 11:24:02 +0200 |
| commit | 6d49343abb0f90fdb2dd88ca639038cc7302c3dc (patch) | |
| tree | 2318ebf5f07a4c007eea56fd4414e67c177d7754 /lib | |
| parent | aacc4082c747557a04627b304fce07ca7cdae8b2 (diff) | |
parse_options.c: add argument help
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils/parse_options.c | 3 | ||||
| -rw-r--r-- | lib/utils/parse_options.h | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/utils/parse_options.c b/lib/utils/parse_options.c index 6928e481..b891066b 100644 --- a/lib/utils/parse_options.c +++ b/lib/utils/parse_options.c @@ -39,6 +39,9 @@ void parse_usage_and_die(const char * const * usage, const struct options *opt) if (opt->long_name) pos += fprintf(stderr, "--%s", opt->long_name); + if (opt->argh) + pos += fprintf(stderr, " <%s>", opt->argh); + if (pos <= USAGE_OPTS_WIDTH) pad = USAGE_OPTS_WIDTH - pos; else diff --git a/lib/utils/parse_options.h b/lib/utils/parse_options.h index fe76a7f3..c9d849f7 100644 --- a/lib/utils/parse_options.h +++ b/lib/utils/parse_options.h @@ -18,12 +18,20 @@ struct options { int short_name; const char *long_name; void *value; + const char *argh; const char *help; }; +/* + * s - short_name + * l - long_name + * v - value + * a - argh argument help + * h - help + */ #define OPT_END() { OPTION_END } -#define OPT_BOOL(s, l, v, h) { OPTION_BOOL, (s), (l), (v), (h) } -#define OPT_STRING(s, l, v, h) { OPTION_STRING, (s), (l), (v), (h) } +#define OPT_BOOL(s, l, v, h) { OPTION_BOOL, (s), (l), (v), NULL, (h) } +#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } void parse_opts(int argc, char **argv, const struct options *opt, const char * const usage[]); |
