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.
This commit is contained in:
Arnaud Bonatti
2019-08-25 21:35:38 +02:00
parent a6ef0debab
commit 56a6d90a4d
2 changed files with 12 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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;
/**