[glib] gsettings: implemented --version command



commit bfb6ff0dbd587841366cc4fa04d1da549dc3e9d7
Author: David Gomes <davidrafagomes gmail com>
Date:   Wed Apr 3 20:15:49 2013 +0100

    gsettings: implemented --version command
    
    This was discussed in
    https://bugzilla.gnome.org/show_bug.cgi?id=697131

 gio/completion/gsettings |    2 +-
 gio/gsettings-tool.c     |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gio/completion/gsettings b/gio/completion/gsettings
index 145c6a8..21f5c6d 100644
--- a/gio/completion/gsettings
+++ b/gio/completion/gsettings
@@ -21,7 +21,7 @@ __gsettings() {
 
   case "$((${COMP_CWORD}-$coffset))" in
     1)
-      choices=$'--schemadir\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children 
\nlist-recursively \nget \nrange \nset \nreset \nreset-recursively \nwritable \nmonitor'
+      choices=$'--schemadir\n--version\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys 
\nlist-children \nlist-recursively \nget \nrange \nset \nreset \nreset-recursively \nwritable \nmonitor'
       ;;
 
     2)
diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c
index 8398793..57beb7b 100644
--- a/gio/gsettings-tool.c
+++ b/gio/gsettings-tool.c
@@ -149,6 +149,15 @@ output_list (const gchar * const *list)
 }
 
 static void
+gsettings_print_version (GSettings   *settings,
+                         const gchar *key,
+                         const gchar *value)
+{
+  g_print ("%d.%d.%d\n", glib_major_version, glib_minor_version,
+           glib_micro_version);
+}
+
+static void
 gsettings_list_schemas (GSettings   *settings,
                         const gchar *key,
                         const gchar *value)
@@ -530,6 +539,12 @@ gsettings_help (gboolean     requested,
       synopsis = "[COMMAND]";
     }
 
+  else if (strcmp (command, "--version") == 0)
+    {
+      description = _("Print version information and exit");
+      synopsis = "";
+    }
+
   else if (strcmp (command, "list-schemas") == 0)
     {
       description = _("List the installed (non-relocatable) schemas");
@@ -736,6 +751,9 @@ main (int argc, char **argv)
   if (strcmp (argv[1], "help") == 0)
     return gsettings_help (TRUE, argv[2]);
 
+  else if (argc == 2 && strcmp (argv[1], "--version") == 0)
+    function = gsettings_print_version;
+
   else if (argc == 2 && strcmp (argv[1], "list-schemas") == 0)
     function = gsettings_list_schemas;
 


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