diff options
author | Werner Koch <wk@gnupg.org> | 2020-03-06 11:10:36 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-03-06 11:10:36 +0100 |
commit | c59bf5824aafe938d5ab0d69079b9d93debc19fe (patch) | |
tree | c0a69785a6faac36201769a977873b6f701630c3 /tests | |
parent | 969abd302211262562df93ae5412ee319aae69e6 (diff) | |
download | libgpg-error-c59bf5824aafe938d5ab0d69079b9d93debc19fe.tar.gz |
core: Add features for pretty printing the help
* src/gpg-error.h.in (ARGPARSE_OPT_HEADER): New.
(ARGPARSE_OPT_VERBATIM): New.
(ARGPARSE_verbatim): New.
(ARGPARSE_header): New.
* src/argparse.c (show_help): Implement them.
--
These two macros are useful for custom help screens. In contrast to
the ARGPARSE_group hack they do not need a short option number (we use
1 here as a surrogate) and not the "@" hack. Thus already translated
strings can be used. ARGPARSE_header further allows to specify a
symbolic name for the group and does some minor formatting. If such a
symbolic name is given --dump-option-table also emits this as a pseudo
option for consumption by GUIs which for example use tabs to group
options.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/t-argparse.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/t-argparse.c b/tests/t-argparse.c index 80da5ac..8ba5841 100644 --- a/tests/t-argparse.c +++ b/tests/t-argparse.c @@ -65,6 +65,7 @@ int main (int argc, char **argv) { gpgrt_opt_t opts[] = { + ARGPARSE_verbatim("Now for the options:\n"), ARGPARSE_x ('v', "verbose", NONE, 0, "Laut sein"), ARGPARSE_s_n('e', "echo" , ("Zeile ausgeben, damit wir sehen, " "was wir eingegeben haben")), @@ -72,12 +73,14 @@ main (int argc, char **argv) ARGPARSE_s_s('o', "output", 0 ), ARGPARSE_o_s('c', "cross-ref", "cross-reference erzeugen\n" ), /* Note that on a non-utf8 terminal the ß might garble the output. */ + ARGPARSE_header("extra-options", "List of extra options"), ARGPARSE_s_n('s', "street","|Straße|set the name of the street to Straße"), ARGPARSE_o_i('m', "my-option", 0), ARGPARSE_o_i('M', "not-my-option", 0), ARGPARSE_s_n(500, "a-long-option", 0 ), ARGPARSE_conffile(501, "options", "|FILE|read options from FILE"), ARGPARSE_noconffile(502, "no-options", "Ignore conf files"), + ARGPARSE_verbatim("This epilog consists\nof only 2 lines\n"), ARGPARSE_end() }; gpgrt_argparse_t pargs = { &argc, &argv, (ARGPARSE_FLAG_ALL |