[geary] Fix nits in command line handling



commit a987318aeec5f6bf776b639e88c77ab023fe3fb3
Author: Charles Lindsay <chaz yorba org>
Date:   Tue Jan 28 16:36:40 2014 -0800

    Fix nits in command line handling
    
    Closes: bgo #722647
    Closes: bgo #722463

 src/client/application/geary-application.vala |    5 ++++-
 src/client/application/geary-args.vala        |   22 +++++++++++-----------
 2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index c1acbf6..d355aa1 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -105,7 +105,10 @@ public class GearyApplication : Gtk.Application {
             error("Error registering GearyApplication: %s", e.message);
         }
         
-        Args.parse(args);
+        if (!Args.parse(args)) {
+            exit_status = 1;
+            return true;
+        }
         
         activate();
         foreach (unowned string arg in args) {
diff --git a/src/client/application/geary-args.vala b/src/client/application/geary-args.vala
index 53eeaa0..a7cc578 100644
--- a/src/client/application/geary-args.vala
+++ b/src/client/application/geary-args.vala
@@ -38,12 +38,13 @@ public bool log_folder_normalization = false;
 public bool inspector = false;
 public bool version = false;
 
-public int parse(string[] args) {
-    var context = new OptionContext("");
+public bool parse(string[] args) {
+    var context = new OptionContext("[%s...]".printf(Geary.ComposedEmail.MAILTO_SCHEME));
     context.set_help_enabled(true);
     context.add_main_entries(options, null);
-    context.add_group(Gtk.get_option_group(false));
-    context.set_description("%s\n\n%s\n\t%s\n".printf(
+    context.set_description("%s\n\n%s\n\n%s\n\t%s\n".printf(
+        // This gives a command-line hint on how to open new composer windows with mailto:
+        _("Use %s to open a new composer window").printf(Geary.ComposedEmail.MAILTO_SCHEME),
         GearyApplication.COPYRIGHT, _("Please report comments, suggestions and bugs to:"),
         GearyApplication.BUGREPORT));
     
@@ -52,8 +53,8 @@ public int parse(string[] args) {
     } catch (OptionError error) {
         // i18n: Command line arguments are invalid
         stdout.printf (_("Failed to parse command line options: %s\n"), error.message);
-        stdout.printf("\n%s", context.get_help(true, Gtk.get_option_group(false)));
-        return 1;
+        stdout.printf("\n%s", context.get_help(true, null));
+        return false;
     }
     
     // other than the OptionEntry command-line arguments, the only acceptable arguments are
@@ -63,16 +64,15 @@ public int parse(string[] args) {
         
         if (!arg.has_prefix(Geary.ComposedEmail.MAILTO_SCHEME)) {
             stdout.printf(_("Unrecognized command line option \"%s\"\n").printf(arg));
-            stdout.printf("\n%s", context.get_help(true, Gtk.get_option_group(false)));
+            stdout.printf("\n%s", context.get_help(true, null));
             
-            return 1;
+            return false;
         }
     }
     
     if (version) {
         stdout.printf("%s %s\n", GearyApplication.PRGNAME, GearyApplication.VERSION);
-        
-        return 1;
+        Process.exit(0);
     }
     
     if (log_network)
@@ -102,7 +102,7 @@ public int parse(string[] args) {
     if (log_debug)
         Geary.Logging.log_to(stdout);
     
-    return 0;
+    return true;
 }
 
 }


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