gsettings: implemented --version command

This was discussed in
https://bugzilla.gnome.org/show_bug.cgi?id=697131
This commit is contained in:
David Gomes 2013-04-03 20:15:49 +01:00 committed by Matthias Clasen
parent 4214078f33
commit bfb6ff0dbd
2 changed files with 19 additions and 1 deletions

View File

@ -21,7 +21,7 @@ __gsettings() {
case "$((${COMP_CWORD}-$coffset))" in case "$((${COMP_CWORD}-$coffset))" in
1) 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) 2)

View File

@ -148,6 +148,15 @@ output_list (const gchar * const *list)
g_print ("%s\n", list[i]); g_print ("%s\n", list[i]);
} }
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 static void
gsettings_list_schemas (GSettings *settings, gsettings_list_schemas (GSettings *settings,
const gchar *key, const gchar *key,
@ -530,6 +539,12 @@ gsettings_help (gboolean requested,
synopsis = "[COMMAND]"; synopsis = "[COMMAND]";
} }
else if (strcmp (command, "--version") == 0)
{
description = _("Print version information and exit");
synopsis = "";
}
else if (strcmp (command, "list-schemas") == 0) else if (strcmp (command, "list-schemas") == 0)
{ {
description = _("List the installed (non-relocatable) schemas"); description = _("List the installed (non-relocatable) schemas");
@ -736,6 +751,9 @@ main (int argc, char **argv)
if (strcmp (argv[1], "help") == 0) if (strcmp (argv[1], "help") == 0)
return gsettings_help (TRUE, argv[2]); 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) else if (argc == 2 && strcmp (argv[1], "list-schemas") == 0)
function = gsettings_list_schemas; function = gsettings_list_schemas;