From c59bf5824aafe938d5ab0d69079b9d93debc19fe Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 6 Mar 2020 11:10:36 +0100 Subject: 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 --- tests/t-argparse.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') 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 -- cgit v1.2.1