diff --git a/tools/command.c b/tools/command.c index 0ed486811..36f419db5 100644 --- a/tools/command.c +++ b/tools/command.c @@ -256,6 +256,10 @@ static int _opt_str_to_num(struct command *cmd, const char *str) * check left & right side for possible match */ for (i = middle;;) { +#ifndef MAN_PAGE_GENERATOR + if (!p && (opt_names_alpha[i]->flags & ARG_MAN_ALIAS_OPT)) + return opt_names_alpha[i]->short_opt; /* alias for man only */ +#endif if ((!p && !(opt_names_alpha[i]->flags & ARG_LONG_OPT)) || (p && !opt_names_alpha[i]->short_opt)) return opt_names_alpha[i]->opt_enum; /* Found */ @@ -268,6 +272,10 @@ static int _opt_str_to_num(struct command *cmd, const char *str) for (i = middle + 1; i <= last; ++i) { if (strcmp(opt_names_alpha[i]->long_opt, long_name)) break; +#ifndef MAN_PAGE_GENERATOR + if (!p && (opt_names_alpha[i]->flags & ARG_MAN_ALIAS_OPT)) + return opt_names_alpha[i]->short_opt; /* alias for man only */ +#endif if ((!p && !(opt_names_alpha[i]->flags & ARG_LONG_OPT)) || (p && !opt_names_alpha[i]->short_opt)) return opt_names_alpha[i]->opt_enum; /* Found */ diff --git a/tools/command.h b/tools/command.h index a254a6932..f1a22e50a 100644 --- a/tools/command.h +++ b/tools/command.h @@ -227,9 +227,9 @@ struct command { struct opt_name { const char *desc; - const char long_opt[27];/* --foo */ - const char short_opt; /* -f */ - uint16_t opt_enum; /* foo_ARG */ + const char long_opt[26];/* --foo */ + uint16_t short_opt; /* -f */ + uint16_t opt_enum; /* foo_ARG */ uint16_t val_enum; /* xyz_VAL when --foo takes a val like "--foo xyz" */ uint16_t flags; uint16_t prio; diff --git a/tools/man-generator.c b/tools/man-generator.c index 40cdace9d..d5ac17ab2 100644 --- a/tools/man-generator.c +++ b/tools/man-generator.c @@ -61,6 +61,7 @@ static void *dm_pool_alloc(void *p, size_t size) #define ARG_GROUPABLE 0x00000002 #define ARG_NONINTERACTIVE 0x00000004 #define ARG_LONG_OPT 0x00000008 +#define ARG_MAN_ALIAS_OPT 0x00000010 struct arg_values; /* needed to include vals.h */ @@ -350,6 +351,11 @@ static void _print_man_option(const char *name, int opt_enum, int indent) { int short_opt = opt_names[opt_enum].short_opt; + if (opt_names[opt_enum].flags & ARG_MAN_ALIAS_OPT) { + opt_enum = short_opt; + short_opt = opt_names[short_opt].short_opt; + } + if (short_opt) printf("\\fB-%c\\fP|", short_opt); else if (indent) diff --git a/tools/tools.h b/tools/tools.h index 57a42f411..4d23cb76b 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -62,6 +62,7 @@ #define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */ #define ARG_NONINTERACTIVE 0x00000004 /* only for use in noninteractive mode */ #define ARG_LONG_OPT 0x00000008 /* arg has long format option */ +#define ARG_MAN_ALIAS_OPT 0x00000010 /* option is a man alias for another option */ struct arg_values { char *value;