mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
common: Add feature to ease using argparse's usage().
* common/argparse.c (show_help): Take care of flag value (usage): Ditto. -- It is common that the long usage note starts with the short usage note. The new flag feature allows to combine both. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
eb5f2c0af6
commit
9078b75a73
@ -1239,6 +1239,14 @@ show_help (ARGPARSE_OPTS *opts, unsigned int flags)
|
|||||||
|
|
||||||
show_version ();
|
show_version ();
|
||||||
writestrings (0, "\n", NULL);
|
writestrings (0, "\n", NULL);
|
||||||
|
s = strusage (42);
|
||||||
|
if (s && *s == '1')
|
||||||
|
{
|
||||||
|
s = strusage (40);
|
||||||
|
writestrings (1, s, NULL);
|
||||||
|
if (*s && s[strlen(s)] != '\n')
|
||||||
|
writestrings (1, "\n", NULL);
|
||||||
|
}
|
||||||
s = strusage(41);
|
s = strusage(41);
|
||||||
writestrings (0, s, "\n", NULL);
|
writestrings (0, s, "\n", NULL);
|
||||||
if ( opts[0].description )
|
if ( opts[0].description )
|
||||||
@ -1432,6 +1440,14 @@ usage (int level)
|
|||||||
}
|
}
|
||||||
else if (level == 2)
|
else if (level == 2)
|
||||||
{
|
{
|
||||||
|
p = strusage (42);
|
||||||
|
if (p && *p == '1')
|
||||||
|
{
|
||||||
|
p = strusage (40);
|
||||||
|
writestrings (1, p, NULL);
|
||||||
|
if (*p && p[strlen(p)] != '\n')
|
||||||
|
writestrings (1, "\n", NULL);
|
||||||
|
}
|
||||||
writestrings (0, strusage(41), "\n", NULL);
|
writestrings (0, strusage(41), "\n", NULL);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
@ -1455,6 +1471,10 @@ usage (int level)
|
|||||||
*30..39: Additional program info (with LFs)
|
*30..39: Additional program info (with LFs)
|
||||||
* 40: short usage note (with LF)
|
* 40: short usage note (with LF)
|
||||||
* 41: long usage note (with LF)
|
* 41: long usage note (with LF)
|
||||||
|
* 42: Flag string:
|
||||||
|
* First char is '1':
|
||||||
|
* The short usage notes needs to be printed
|
||||||
|
* before the long usage note.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
strusage( int level )
|
strusage( int level )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user