diff options
author | Werner Koch <[email protected]> | 2015-03-17 10:22:28 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-03-17 10:22:28 +0000 |
commit | 9078b75a73600fc6b7b5502ceee8de032bb9c446 (patch) | |
tree | e4d59397edfc00c777228b026ec33875b0287b6c | |
parent | common: Allow standalone build of argparse.c (diff) | |
download | gnupg-9078b75a73600fc6b7b5502ceee8de032bb9c446.tar.gz gnupg-9078b75a73600fc6b7b5502ceee8de032bb9c446.zip |
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 <[email protected]>
-rw-r--r-- | common/argparse.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/argparse.c b/common/argparse.c index a4d1552e6..e31b67ea5 100644 --- a/common/argparse.c +++ b/common/argparse.c @@ -1239,6 +1239,14 @@ show_help (ARGPARSE_OPTS *opts, unsigned int flags) show_version (); 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); writestrings (0, s, "\n", NULL); if ( opts[0].description ) @@ -1432,6 +1440,14 @@ usage (int level) } 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); exit (0); } @@ -1455,6 +1471,10 @@ usage (int level) *30..39: Additional program info (with LFs) * 40: short 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 * strusage( int level ) |