[glib] glib-compile-resources: Add a --version option



commit bce8b6db8d5f3dacce15982e0f44313f989af5e8
Author: Sam Thursfield <ssssam gmail com>
Date:   Fri Sep 30 22:56:16 2016 +0100

    glib-compile-resources: Add a --version option
    
    There have been some improvements to the tool recently, but it's hard to
    know if those are available on a given system unless the tool provides a
    --version commandline option.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772269

 docs/reference/gio/glib-compile-resources.xml |    7 +++++++
 gio/glib-compile-resources.c                  |    8 ++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/glib-compile-resources.xml b/docs/reference/gio/glib-compile-resources.xml
index c2c1989..f5a1e62 100644
--- a/docs/reference/gio/glib-compile-resources.xml
+++ b/docs/reference/gio/glib-compile-resources.xml
@@ -57,6 +57,13 @@ Print help and exit
 </varlistentry>
 
 <varlistentry>
+<term><option>--version</option></term>
+<listitem><para>
+Print program version and exit
+</para></listitem>
+</varlistentry>
+
+<varlistentry>
 <term><option>--target=<replaceable>TARGET</replaceable></option></term>
 <listitem><para>
 Store the compiled resources in the file <replaceable>TARGET</replaceable>.
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index c497f1a..05d7334 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -603,6 +603,7 @@ main (int argc, char **argv)
   GHashTable *table;
   GHashTable *files;
   gchar *srcfile;
+  gboolean show_version_and_exit = FALSE;
   gchar *target = NULL;
   gchar *binary_target = NULL;
   gboolean generate_automatic = FALSE;
@@ -617,6 +618,7 @@ main (int argc, char **argv)
   const char *linkage = "extern";
   GOptionContext *context;
   GOptionEntry entries[] = {
+    { "version", 0, 0, G_OPTION_ARG_NONE, &show_version_and_exit, N_("Show program version and exit"), NULL 
},
     { "target", 0, 0, G_OPTION_ARG_FILENAME, &target, N_("name of the output file"), N_("FILE") },
     { "sourcedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &sourcedirs, N_("The directories where files are to be 
read from (default to current directory)"), N_("DIRECTORY") },
     { "generate", 0, 0, G_OPTION_ARG_NONE, &generate_automatic, N_("Generate output in the format selected 
for by the target filename extension"), NULL },
@@ -666,6 +668,12 @@ main (int argc, char **argv)
 
   g_option_context_free (context);
 
+  if (show_version_and_exit)
+    {
+      g_print (PACKAGE_VERSION "\n");
+      return 0;
+    }
+
   if (argc != 2)
     {
       g_printerr (_("You should give exactly one file name\n"));


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