[gobject-introspection] Add a --version option to g-ir-compiler and g-ir-generate. Fixes #55



commit be11366bf9036b4cd02cca99f5dfb7dfbf167da6
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sun Dec 16 13:42:27 2018 +0100

    Add a --version option to g-ir-compiler and g-ir-generate. Fixes #55

 docs/g-ir-compiler.1                 | 3 +++
 docs/g-ir-generate.1                 | 3 +++
 docs/website/tools/g-ir-compiler.rst | 3 +++
 docs/website/tools/g-ir-generate.rst | 3 +++
 tools/compiler.c                     | 9 +++++++++
 tools/generate.c                     | 9 +++++++++
 6 files changed, 30 insertions(+)
---
diff --git a/docs/g-ir-compiler.1 b/docs/g-ir-compiler.1
index 65c439bb..48dc5ceb 100644
--- a/docs/g-ir-compiler.1
+++ b/docs/g-ir-compiler.1
@@ -63,6 +63,9 @@ FIXME
 Specifies the shared library where the symbols in the typelib can be
 found. The name of the library should not contain the ending shared
 library suffix.
+.TP
+.B \-\-version
+Show program\(aqs version number and exit
 .UNINDENT
 .SH BUGS
 .sp
diff --git a/docs/g-ir-generate.1 b/docs/g-ir-generate.1
index fb07de75..038d171f 100644
--- a/docs/g-ir-generate.1
+++ b/docs/g-ir-generate.1
@@ -49,6 +49,9 @@ The shared library to read the symbols from.
 .TP
 .BI \-\-output\fB= FILENAME
 Save the resulting output in FILENAME.
+.TP
+.B \-\-version
+Show program\(aqs version number and exit
 .UNINDENT
 .SH BUGS
 .sp
diff --git a/docs/website/tools/g-ir-compiler.rst b/docs/website/tools/g-ir-compiler.rst
index e87a9abd..5c17a7ce 100644
--- a/docs/website/tools/g-ir-compiler.rst
+++ b/docs/website/tools/g-ir-compiler.rst
@@ -49,6 +49,9 @@ OPTIONS
     found. The name of the library should not contain the ending shared
     library suffix.
 
+--version
+    Show program's version number and exit
+
 
 BUGS
 ====
diff --git a/docs/website/tools/g-ir-generate.rst b/docs/website/tools/g-ir-generate.rst
index 662ec10b..931ee449 100644
--- a/docs/website/tools/g-ir-generate.rst
+++ b/docs/website/tools/g-ir-generate.rst
@@ -35,6 +35,9 @@ OPTIONS
 --output=FILENAME
     Save the resulting output in FILENAME.
 
+--version
+    Show program's version number and exit
+
 
 BUGS
 ====
diff --git a/tools/compiler.c b/tools/compiler.c
index 06d87d91..700305ed 100644
--- a/tools/compiler.c
+++ b/tools/compiler.c
@@ -45,6 +45,7 @@ gchar **shlibs = NULL;
 gboolean include_cwd = FALSE;
 gboolean debug = FALSE;
 gboolean verbose = FALSE;
+gboolean show_version = FALSE;
 
 static gboolean
 write_out_typelib (gchar *prefix,
@@ -135,6 +136,7 @@ static GOptionEntry options[] =
   { "shared-library", 'l', 0, G_OPTION_ARG_FILENAME_ARRAY, &shlibs, "shared library", "FILE" }, 
   { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "show debug messages", NULL }, 
   { "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, "show verbose messages", NULL }, 
+  { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, "show program's version number and exit", NULL },
   { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
   { NULL, }
 };
@@ -174,6 +176,13 @@ main (int argc, char ** argv)
 
   g_log_set_default_handler (log_handler, NULL);
 
+  if (show_version)
+    {
+      g_printf ("g-ir-compiler %u.%u.%u\n",
+                GI_MAJOR_VERSION, GI_MINOR_VERSION, GI_MICRO_VERSION);
+      return 0;
+    }
+
   if (!input) 
     { 
       g_fprintf (stderr, "no input files\n"); 
diff --git a/tools/generate.c b/tools/generate.c
index 36e1d05a..143f01fd 100644
--- a/tools/generate.c
+++ b/tools/generate.c
@@ -41,6 +41,7 @@ main (int argc, char *argv[])
   GOptionContext *context;
   GError *error = NULL;
   gboolean needs_prefix;
+  gboolean show_version = FALSE;
   gint i;
   GOptionEntry options[] =
     {
@@ -48,6 +49,7 @@ main (int argc, char *argv[])
       { "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
       { "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search 
path", NULL },
       { "all", 0, 0, G_OPTION_ARG_NONE, &show_all, "show all available information", NULL, },
+      { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, "show program's version number and exit", NULL },
       { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
       { NULL, }
     };
@@ -67,6 +69,13 @@ main (int argc, char *argv[])
       return 1;
     }
 
+  if (show_version)
+    {
+      g_printf ("g-ir-generate %u.%u.%u\n",
+                GI_MAJOR_VERSION, GI_MINOR_VERSION, GI_MICRO_VERSION);
+      return 0;
+    }
+
   if (!input)
     {
       g_fprintf (stderr, "no input files\n");


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