From ae92cd897e836baf18e0bbe2d6a20964efe3dbd7 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 9 Jul 2020 06:21:42 +0100 Subject: [PATCH] optget.c: proper formatting for '--help | --man' (re: 6916a873) This shows a better layout in '--man' or '--nroff' output. src/lib/libast/misc/optget.c: - Incorporate the '--help | --man' addition in the printf format instead of hardcoding it in the default options string. --- src/lib/libast/misc/optget.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/libast/misc/optget.c b/src/lib/libast/misc/optget.c index 6c5fcab37..7c735bbac 100644 --- a/src/lib/libast/misc/optget.c +++ b/src/lib/libast/misc/optget.c @@ -1627,7 +1627,7 @@ args(register Sfio_t* sp, register char* p, register int n, int flags, int style else { sep = ' '; - o = T(NiL, ID, "options | --help | --man"); + o = T(NiL, ID, "options"); b = style == STYLE_nroff ? "\\ " : " "; for (;;) { @@ -1636,7 +1636,11 @@ args(register Sfio_t* sp, register char* p, register int n, int flags, int style { if (!(a = id)) a = "..."; - sfprintf(sp, "\t%s%s%s%s[%s%s%s%s%s]", font(FONT_BOLD, style, 1), a, font(FONT_BOLD, style, 0), b, b, font(FONT_ITALIC, style, 1), o, font(FONT_ITALIC, style, 0), b); + sfprintf(sp, "\t%s%s%s%s[%s%s%s%s%s|%s%s--help%s%s|%s%s--man%s%s]", + font(FONT_BOLD, style, 1), a, font(FONT_BOLD, style, 0), b, + b, font(FONT_ITALIC, style, 1), o, font(FONT_ITALIC, style, 0), b, + b, font(FONT_ITALIC, style, 1), font(FONT_ITALIC, style, 0), b, + b, font(FONT_ITALIC, style, 1), font(FONT_ITALIC, style, 0), b); } else if (a) sfprintf(sp, "%*.*s%s%s%s[%s%s%s]", OPT_USAGE - 1, OPT_USAGE - 1, T(NiL, ID, "Or:"), b, a, b, b, o, b); @@ -1645,7 +1649,7 @@ args(register Sfio_t* sp, register char* p, register int n, int flags, int style if (!(a = error_info.id) && !(a = id)) a = "..."; if (!sfstrtell(sp)) - sfprintf(sp, "[%s%s%s]", b, o, b); + sfprintf(sp, "[%s%s%s|%s--help%s|%s--man%s]", b, o, b, b, b, b, b); } if (!t) break;