Add -V/--version option to print the commit and exit.
authorTom Adams <tom@holizz.com>
Wed, 8 Jul 2009 11:07:52 +0000 (12:07 +0100)
committerTom Adams <tom@holizz.com>
Sat, 11 Jul 2009 10:38:44 +0000 (11:38 +0100)
uzbl.c
uzbl.h

diff --git a/uzbl.c b/uzbl.c
index c82e7be..a998b91 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -75,6 +75,8 @@ GOptionEntry entries[] =
         "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" },
     { "socket",  's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
         "Socket ID", "SOCKET" },
+    { "version",  'V', 0, G_OPTION_ARG_NONE, &uzbl.behave.print_version,
+        "Print the version and exit", NULL },
     { NULL,      0, 0, 0, NULL, NULL, NULL }
 };
 
@@ -2700,6 +2702,11 @@ main (int argc, char* argv[]) {
     g_option_context_parse (context, &argc, &argv, NULL);
     g_option_context_free(context);
 
+    if (uzbl.behave.print_version) {
+        printf("Commit: %s\n", COMMIT);
+        exit(0);
+    }
+
     gchar *uri_override = (uzbl.state.uri ? g_strdup(uzbl.state.uri) : NULL);
     if (argc > 1 && !uzbl.state.uri)
         uri_override = g_strdup(argv[1]);
diff --git a/uzbl.h b/uzbl.h
index eba060e..9a7ccd2 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -171,6 +171,7 @@ typedef struct {
     gchar*   cmd_indicator;
     GString* html_buffer;
     guint    html_timeout;
+    gboolean print_version;
 
     /* command list: name -> Command  */
     GHashTable* commands;