summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Bonatti <arnaud.bonatti@gmail.com>2019-08-25 21:35:38 +0200
committerArnaud Bonatti <arnaud.bonatti@gmail.com>2019-09-12 16:50:19 +0200
commit56a6d90a4d75a8af3f57c8d63c57bd1f1abb47f8 (patch)
tree36de8df1b7f0763c9d205234c5ee6826faffd3f9
parenta6ef0debabd1ae8710dfbb0d59079b73c33de8c3 (diff)
downloadglib-56a6d90a4d75a8af3f57c8d63c57bd1f1abb47f8.tar.gz
Add G_OPTION_FLAG_APPEND_EMPTY_LINE
This flag adds in --help output an empty line after the line of the option, allowing to visually group options.
-rw-r--r--glib/goption.c11
-rw-r--r--glib/goption.h5
2 files changed, 12 insertions, 4 deletions
diff --git a/glib/goption.c b/glib/goption.c
index 5411e8c5d..c599d06fe 100644
--- a/glib/goption.c
+++ b/glib/goption.c
@@ -729,9 +729,14 @@ print_entry (GOptionGroup *group,
if (entry->arg_description)
g_string_append_printf (str, "=%s", TRANSLATE (group, entry->arg_description));
- g_string_append_printf (string, "%s%*s %s\n", str->str,
- (int) (max_length + 4 - _g_utf8_strwidth (str->str)), "",
- entry->description ? TRANSLATE (group, entry->description) : "");
+ if (entry->flags & G_OPTION_FLAG_APPEND_EMPTY_LINE)
+ g_string_append_printf (string, "%s%*s %s\n\n", str->str,
+ (int) (max_length + 4 - _g_utf8_strwidth (str->str)), "",
+ entry->description ? TRANSLATE (group, entry->description) : "");
+ else
+ g_string_append_printf (string, "%s%*s %s\n", str->str,
+ (int) (max_length + 4 - _g_utf8_strwidth (str->str)), "",
+ entry->description ? TRANSLATE (group, entry->description) : "");
g_string_free (str, TRUE);
}
diff --git a/glib/goption.h b/glib/goption.h
index 63552fb0d..7a07901b5 100644
--- a/glib/goption.h
+++ b/glib/goption.h
@@ -75,6 +75,8 @@ typedef struct _GOptionEntry GOptionEntry;
* where aliasing is necessary to model some legacy commandline interface.
* It is not safe to use this option, unless all option groups are under
* your direct control. Since 2.8.
+ * @G_OPTION_FLAG_APPEND_EMPTY_LINE: This flag adds an empty line after the
+ * one of the option, allowing to visually group options. Since: 2.63.1.
*
* Flags which modify individual options.
*/
@@ -87,7 +89,8 @@ typedef enum
G_OPTION_FLAG_NO_ARG = 1 << 3,
G_OPTION_FLAG_FILENAME = 1 << 4,
G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5,
- G_OPTION_FLAG_NOALIAS = 1 << 6
+ G_OPTION_FLAG_NOALIAS = 1 << 6,
+ G_OPTION_FLAG_APPEND_EMPTY_LINE = 1 << 7
} GOptionFlags;
/**