[balsa/gtk3] Handle -h option



commit 8f385ec287033f4e00e02263f2d90fbbd7798e1c
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Feb 23 18:07:04 2013 -0500

    Handle -h option
    
        * src/main.c (handle_remote): handle -h option.

 ChangeLog  |    4 ++++
 src/main.c |   14 +++++++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e9f446c..9707dc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-02-23  Peter Bloomfield
 
+       * src/main.c (handle_remote): handle -h option.
+
+2013-02-23  Peter Bloomfield
+
        * libbalsa/mailbox.c (lbm_msgno_changed),
        (libbalsa_mailbox_msgno_changed): make sure parent message is
        checked.
diff --git a/src/main.c b/src/main.c
index 592e34a..3724b08 100644
--- a/src/main.c
+++ b/src/main.c
@@ -735,6 +735,7 @@ handle_remote(int argc, char **argv,
         {"help", '?', 0, G_OPTION_ARG_NONE, &help, NULL, NULL},
         {NULL}
     };
+    gboolean rc;
     GError *error;
     gint status = 0;
 
@@ -754,7 +755,18 @@ handle_remote(int argc, char **argv,
     cmd_open_unread_mailbox = FALSE;
     cmd_open_inbox = FALSE;
 
-    if (!g_option_context_parse(context, &argc, &argv, &error)) {
+    rc = g_option_context_parse(context, &argc, &argv, &error);
+    /* We offer --help and -? as help options;
+     * GOptionContext promises --help and -h, but -h causes an error.
+     * If we got an error, we check to see if it was caused by -h,
+     * and if so, honor it: */
+    if (!rc && strcmp(*++argv, "-h") == 0) {
+        rc = help = TRUE;
+        g_error_free(error);
+    }
+
+    if (!rc) {
+        /* Some other bad option */
         g_application_command_line_printerr(command_line, "%s\n",
                                             error->message);
         g_error_free(error);


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