aboutsummaryrefslogtreecommitdiff
path: root/src/opthelp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/opthelp.c')
-rw-r--r--src/opthelp.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/opthelp.c b/src/opthelp.c
index 58deeed..75e48d2 100644
--- a/src/opthelp.c
+++ b/src/opthelp.c
@@ -118,9 +118,20 @@ grecs_print_help(struct grecs_proginfo *pinfo)
struct grecs_opthelp *opthelp;
size_t optcount;
- printf("%s %s [%s]... %s\n",
- _("Usage:"), pinfo->progname, _("OPTION"),
+ printf("%s %s ",
+ _("Usage:"), pinfo->progname);
+ if (pinfo->subcmd)
+ printf("%s ", pinfo->subcmd[0]);
+ printf("[%s]... %s\n",
+ _("OPTION"),
!ISEMPTY(pinfo->args_doc) ? gettext(pinfo->args_doc) : "");
+ if (pinfo->subcmd && pinfo->subcmd[1]) {
+ const char **p;
+
+ printf("%s: ", pinfo->subcmd[2] ? _("Aliases") : _("Alias"));
+ for (p = pinfo->subcmd + 1; *p; p++)
+ printf("%s%c", *p, p[1] ? ' ' : '\n');
+ }
if (!ISEMPTY(pinfo->docstring))
print_option_descr(gettext(pinfo->docstring), 0, RMARGIN);
putchar('\n');
@@ -255,6 +266,8 @@ grecs_print_usage(struct grecs_proginfo *pinfo)
buf = grecs_malloc(bufsize);
n = snprintf(buf, bufsize, "%s %s ", _("Usage:"), pinfo->progname);
+ if (pinfo->subcmd)
+ n += snprintf(buf + n, bufsize - n, "%s ", pinfo->subcmd[0]);
/* Print a list of short options without arguments. */
for (i = nidx = 0; i < optcount; i++)
@@ -368,6 +381,17 @@ grecs_print_usage(struct grecs_proginfo *pinfo)
}
#endif
FLUSH;
+
+ if (pinfo->subcmd && pinfo->subcmd[1]) {
+ const char **p;
+
+ printf("%s: %s", pinfo->subcmd[2] ? _("Aliases") : _("Alias"),
+ pinfo->progname);
+ for (p = pinfo->subcmd + 1; *p; p++)
+ printf(" %s", *p);
+ putchar('\n');
+ }
+
free(optidx);
free(buf);
}

Return to:

Send suggestions and report system problems to the System administrator.