From 0b8e42a2f521d706b32defc2359545d0bc8f086d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 25 May 2005 02:42:21 +0000 Subject: [PATCH] If the remaining argument has an arg_description, display the synopsis as 2005-05-24 Matthias Clasen * glib/goption.c (print_help): If the remaining argument has an arg_description, display the synopsis as PROGNAME [OPTION...] REST (#305346, Noah Levitt) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-12 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ glib/goption.c | 20 +++++++++++++++++++- 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ad552745..31cd8657 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-24 Matthias Clasen + + * glib/goption.c (print_help): If the remaining argument + has an arg_description, display the synopsis as + PROGNAME [OPTION...] REST (#305346, Noah Levitt) + 2005-05-20 Federico Mena Quintero Merged from glib-2-6: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ad552745..31cd8657 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2005-05-24 Matthias Clasen + + * glib/goption.c (print_help): If the remaining argument + has an arg_description, display the synopsis as + PROGNAME [OPTION...] REST (#305346, Noah Levitt) + 2005-05-20 Federico Mena Quintero Merged from glib-2-6: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index ad552745..31cd8657 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +2005-05-24 Matthias Clasen + + * glib/goption.c (print_help): If the remaining argument + has an arg_description, display the synopsis as + PROGNAME [OPTION...] REST (#305346, Noah Levitt) + 2005-05-20 Federico Mena Quintero Merged from glib-2-6: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ad552745..31cd8657 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2005-05-24 Matthias Clasen + + * glib/goption.c (print_help): If the remaining argument + has an arg_description, display the synopsis as + PROGNAME [OPTION...] REST (#305346, Noah Levitt) + 2005-05-20 Federico Mena Quintero Merged from glib-2-6: diff --git a/glib/goption.c b/glib/goption.c index 234c1c93..96629665 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -437,9 +437,27 @@ print_help (GOptionContext *context, GOptionEntry *entry; GHashTable *shadow_map; gboolean seen[256]; + gchar *rest_description; - g_print ("%s\n %s %s %s\n\n", + rest_description = NULL; + if (context->main_group) + { + for (i = 0; i < context->main_group->n_entries; i++) + { + entry = &context->main_group->entries[i]; + if (entry->long_name[0] == 0) + { + rest_description = entry->arg_description; + break; + } + } + } + + g_print ("%s\n %s %s%s%s%s%s\n\n", _("Usage:"), g_get_prgname(), _("[OPTION...]"), + rest_description ? " " : "", + rest_description ? rest_description : "", + context->parameter_string ? " " : "", context->parameter_string ? context->parameter_string : ""); memset (seen, 0, sizeof (gboolean) * 256); -- 2.34.1