summaryrefslogtreecommitdiff
path: root/src/gpg-error.h.in
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-03-06 11:10:36 +0100
committerWerner Koch <wk@gnupg.org>2020-03-06 11:10:36 +0100
commitc59bf5824aafe938d5ab0d69079b9d93debc19fe (patch)
treec0a69785a6faac36201769a977873b6f701630c3 /src/gpg-error.h.in
parent969abd302211262562df93ae5412ee319aae69e6 (diff)
downloadlibgpg-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 'src/gpg-error.h.in')
-rw-r--r--src/gpg-error.h.in21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index b0b1972..9042a0f 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -1230,6 +1230,8 @@ typedef struct
#define ARGPARSE_OPT_IGNORE (1<<6) /* Ignore command or option. */
#define ARGPARSE_OPT_COMMAND (1<<7) /* The argument is a command. */
#define ARGPARSE_OPT_CONFFILE (1<<8) /* The value is a conffile. */
+#define ARGPARSE_OPT_HEADER (1<<9) /* The value is printed as a header. */
+#define ARGPARSE_OPT_VERBATIM (1<<10)/* The value is printed verbatim. */
#define ARGPARSE_ATTR_FORCE (1<<14)/* Attribute force is set. */
#define ARGPARSE_ATTR_IGNORE (1<<15)/* Attribute ignore is set. */
@@ -1304,15 +1306,28 @@ typedef struct
#define ARGPARSE_noconffile(s,l,d) \
{ (s), (l), (ARGPARSE_TYPE_NONE|ARGPARSE_OPT_CONFFILE), (d) }
+/* This macro is for stub or obsolete options. */
#define ARGPARSE_ignore(s,l) \
- { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
+ { (s), (l), (ARGPARSE_OPT_IGNORE), "@" }
+/* This is a legacy version of ARGPARSE_verbatim which really does
+ * verbatim printing. */
#define ARGPARSE_group(s,d) \
- { (s), NULL, 0, (d) }
+ { (s), NULL, 0, (d) }
+
+/* Verbatim print the string D in the help output. It does not make
+ * use of the "@" hack as ARGPARSE_group does. */
+#define ARGPARSE_verbatim(d) \
+ { 1, NULL, (ARGPARSE_OPT_VERBATIM), (d) }
+
+/* Same as ARGPARSE_verbatim but also print a colon and a LF. N can
+ * be used give a symbolic name to the header. */
+#define ARGPARSE_header(n,d) \
+ { 1, (n), (ARGPARSE_OPT_HEADER), (d) }
/* Mark the end of the list (mandatory). */
#define ARGPARSE_end() \
- { 0, NULL, 0, NULL }
+ { 0, NULL, 0, NULL }
#endif /* GPGRT_ENABLE_ARGPARSE_MACROS */