[Gnucash-changes] r12838 - gnucash/trunk/src/bin - Catch --version argument before booting Guile.

Chris Shoemaker chris at cvs.gnucash.org
Tue Jan 17 22:46:53 EST 2006


Author: chris
Date: 2006-01-17 22:46:53 -0500 (Tue, 17 Jan 2006)
New Revision: 12838
Trac: http://svn.gnucash.org/trac/changeset/12838

Modified:
   gnucash/trunk/src/bin/Makefile.am
   gnucash/trunk/src/bin/gnucash-bin.c
Log:
  Catch --version argument before booting Guile.
  Also show svn revision info if binary was built from svn.


Modified: gnucash/trunk/src/bin/Makefile.am
===================================================================
--- gnucash/trunk/src/bin/Makefile.am	2006-01-17 22:53:44 UTC (rev 12837)
+++ gnucash/trunk/src/bin/Makefile.am	2006-01-18 03:46:53 UTC (rev 12838)
@@ -2,11 +2,13 @@
 SUBDIRS = . overrides test
 
 AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS} ${GNOME_CFLAGS} ${GTK_CFLAGS} \
+-I${top_builddir}/src/gnome-utils \
 -I${top_builddir}/src/gnc-module
 
 bin_PROGRAMS = gnucash-bin
 gnucash_bin_SOURCES = gnucash-bin.c
 gnucash_bin_LDADD = ${GUILE_LIBS} ${GLIB_LIBS} ${GNOME_LIBS} ${GTK_LIBS} \
+${top_srcdir}/src/gnome-utils/libgncmod-gnome-utils.la \
 ${top_srcdir}/src/gnc-module/libgncmodule.la
 
 gnucash: gnucash.in ${top_builddir}/config.status Makefile

Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c	2006-01-17 22:53:44 UTC (rev 12837)
+++ gnucash/trunk/src/bin/gnucash-bin.c	2006-01-18 03:46:53 UTC (rev 12838)
@@ -23,12 +23,48 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <popt.h>
 #include <libguile.h>
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 #include "glib.h"
 #include "gnc-module.h"
 #include "i18n.h"
+#include "gnc-version.h"
+#include "config.h"
 
+static int gnucash_show_version;
+static int is_development_version = TRUE;
+
+void 
+gnucash_command_line(int argc, char **argv)
+{
+    poptContext pc;
+    int rc;
+
+    struct poptOption options[] = {
+        //POPT_AUTOHELP
+        {"version", 'v', POPT_ARG_NONE, &gnucash_show_version, 1, 
+         N_("Display GnuCash version"), NULL},
+        POPT_TABLEEND
+    };
+
+    pc = poptGetContext(NULL, argc, (const char **)argv, options, 0);
+    
+    while ((rc = poptGetNextOpt(pc)) > 0);
+
+    if (gnucash_show_version) {
+        printf("GnuCash %s %s\n", VERSION, 
+               is_development_version ? _("development version") : "");
+#ifdef GNUCASH_SVN
+        printf("built %s from svn r%s\n", GNUCASH_BUILD_DATE, GNUCASH_SVN_REV);
+#endif 
+        exit(0);
+    }
+    
+    poptFreeContext(pc);
+}
+
 static void
 inner_main (void *closure, int argc, char **argv)
 {
@@ -58,6 +94,7 @@
 
     gtk_init (&argc, &argv);
     gnc_module_system_init();
+    gnucash_command_line(argc, argv);
 
     scm_boot_guile(argc, argv, inner_main, 0);
     exit(0); /* never reached */



More information about the gnucash-changes mailing list