1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00

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.
This commit is contained in:
Martijn Dekker 2020-07-09 06:21:42 +01:00
parent 9526b3fa08
commit ae92cd897e

View file

@ -1627,7 +1627,7 @@ args(register Sfio_t* sp, register char* p, register int n, int flags, int style
else else
{ {
sep = ' '; sep = ' ';
o = T(NiL, ID, "options | --help | --man"); o = T(NiL, ID, "options");
b = style == STYLE_nroff ? "\\ " : " "; b = style == STYLE_nroff ? "\\ " : " ";
for (;;) for (;;)
{ {
@ -1636,7 +1636,11 @@ args(register Sfio_t* sp, register char* p, register int n, int flags, int style
{ {
if (!(a = id)) if (!(a = id))
a = "..."; 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) 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); 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)) if (!(a = error_info.id) && !(a = id))
a = "..."; a = "...";
if (!sfstrtell(sp)) 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) if (!t)
break; break;