[glib/arnaudb/option-flag-append-empty-line] Add G_OPTION_FLAG_APPEND_EMPTY_LINE



commit 56a6d90a4d75a8af3f57c8d63c57bd1f1abb47f8
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Aug 25 21:35:38 2019 +0200

    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.

 glib/goption.c | 11 ++++++++---
 glib/goption.h |  5 ++++-
 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;
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]