[glib] GOptionContext: Improve help in simple cases
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GOptionContext: Improve help in simple cases
- Date: Mon, 25 May 2015 17:30:35 +0000 (UTC)
commit 126c685f4aa627a8190e09adfc8ab0733c14a6ea
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 25 13:26:48 2015 -0400
GOptionContext: Improve help in simple cases
Only add [OPTION...] to the usage line if the context
has options. And shorten "Application Options" to just
"Options" if we don't have to differentiate from other
kinds of options.
glib/goption.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/glib/goption.c b/glib/goption.c
index 7d59eee..8a1848d 100644
--- a/glib/goption.c
+++ b/glib/goption.c
@@ -854,8 +854,11 @@ g_option_context_get_help (GOptionContext *context,
}
}
- g_string_append_printf (string, "%s\n %s %s",
- _("Usage:"), g_get_prgname(), _("[OPTION...]"));
+ g_string_append_printf (string, "%s\n %s", _("Usage:"), g_get_prgname());
+ if (context->help_enabled ||
+ context->main_group->n_entries > 0 ||
+ context->groups != NULL)
+ g_string_append_printf (string, " %s", _("[OPTION...]"));
if (rest_description)
{
@@ -1040,7 +1043,10 @@ g_option_context_get_help (GOptionContext *context,
{
list = context->groups;
- g_string_append (string, _("Application Options:"));
+ if (context->help_enabled || list)
+ g_string_append (string, _("Application Options:"));
+ else
+ g_string_append (string, _("Options:"));
g_string_append (string, "\n");
if (context->main_group)
for (i = 0; i < context->main_group->n_entries; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]