summaryrefslogtreecommitdiff
path: root/libmailutils
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-04-29 19:12:00 +0300
committerSergey Poznyakoff <gray@gnu.org>2021-04-29 19:36:55 +0300
commit8bda0876ae606be9f5d5a00f15e412bc4186d86c (patch)
treeb1791a3f744ed43e81ad3afcbe57cb63db1f2699 /libmailutils
parent9eca2fa180cb562128a9db1bad8c77d0b3bdc6a4 (diff)
downloadmailutils-8bda0876ae606be9f5d5a00f15e412bc4186d86c.tar.gz
mailutils-8bda0876ae606be9f5d5a00f15e412bc4186d86c.tar.bz2
libopt: don't show hidden options in the --usage output.
* libmailutils/opt/help.c (option_summary): Skip options with MU_OPTION_HIDDEN bit set. (mu_option_describe_options): Reset margin to 0 so that eventual extra_doc is formatted correctly.
Diffstat (limited to 'libmailutils')
-rw-r--r--libmailutils/opt/help.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libmailutils/opt/help.c b/libmailutils/opt/help.c
index ee21a14cf..c22de0cb3 100644
--- a/libmailutils/opt/help.c
+++ b/libmailutils/opt/help.c
@@ -332,11 +332,12 @@ mu_option_describe_options (mu_stream_t str, struct mu_parseopt *po)
for (i = 0; i < po->po_optc; )
i = print_option (str, po, i, &argsused);
+
+ set_margin (str, 0);
mu_stream_printf (str, "\n");
if (argsused && !(po->po_flags & MU_PARSEOPT_SINGLE_DASH) && dup_args_note)
{
- set_margin (str, 0);
mu_stream_printf (str, "%s\n\n",
_("Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options."));
}
@@ -454,7 +455,9 @@ option_summary (struct mu_parseopt *po, mu_stream_t str)
{
/* Print a list of short options without arguments. */
for (i = nidx = 0; i < optcnt; i++)
- if (MU_OPTION_IS_VALID_SHORT_OPTION (optbuf[i]) && !optbuf[i]->opt_arg)
+ if (MU_OPTION_IS_VALID_SHORT_OPTION (optbuf[i]) &&
+ !(optbuf[i]->opt_flags & MU_OPTION_HIDDEN) &&
+ !optbuf[i]->opt_arg)
idxbuf[nidx++] = i;
if (nidx)
@@ -471,7 +474,9 @@ option_summary (struct mu_parseopt *po, mu_stream_t str)
/* Print a list of short options with arguments. */
for (i = nidx = 0; i < optcnt; i++)
{
- if (MU_OPTION_IS_VALID_SHORT_OPTION (optbuf[i]) && optbuf[i]->opt_arg)
+ if (MU_OPTION_IS_VALID_SHORT_OPTION (optbuf[i]) &&
+ !(optbuf[i]->opt_flags & MU_OPTION_HIDDEN) &&
+ optbuf[i]->opt_arg)
idxbuf[nidx++] = i;
}
@@ -494,7 +499,8 @@ option_summary (struct mu_parseopt *po, mu_stream_t str)
/* Print a list of long options */
for (i = nidx = 0; i < optcnt; i++)
{
- if (MU_OPTION_IS_VALID_LONG_OPTION (optbuf[i]))
+ if (MU_OPTION_IS_VALID_LONG_OPTION (optbuf[i]) &&
+ !(optbuf[i]->opt_flags & MU_OPTION_HIDDEN))
idxbuf[nidx++] = i;
}

Return to:

Send suggestions and report system problems to the System administrator.