Added describe command to gsettings command-line tool.

describe command shows description of given gsettings key.
Added documentation of describe command to gsettings man page.
This commit is contained in:
Jeremy Whiting 2016-08-25 12:39:33 -06:00
parent edfbfc1827
commit 8fd72838ce
2 changed files with 34 additions and 0 deletions

View File

@ -48,6 +48,12 @@
<arg choice="plain"><replaceable>SCHEMA</replaceable><arg choice="opt">:<replaceable>PATH</replaceable></arg></arg> <arg choice="plain"><replaceable>SCHEMA</replaceable><arg choice="opt">:<replaceable>PATH</replaceable></arg></arg>
<arg choice="plain"><replaceable>KEY</replaceable></arg> <arg choice="plain"><replaceable>KEY</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>gsettings</command>
<arg choice="plain">describe</arg>
<arg choice="plain"><replaceable>SCHEMA</replaceable><arg choice="opt">:<replaceable>PATH</replaceable></arg></arg>
<arg choice="plain"><replaceable>KEY</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>gsettings</command> <command>gsettings</command>
<arg choice="plain">set</arg> <arg choice="plain">set</arg>
@ -157,6 +163,13 @@ Queries the range of valid values for <replaceable>KEY</replaceable>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>describe</option></term>
<listitem><para>
Queries the description of valid values for <replaceable>KEY</replaceable>.
</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>set</option></term> <term><option>set</option></term>
<listitem><para> <listitem><para>

View File

@ -270,6 +270,14 @@ gsettings_list_recursively (void)
} }
} }
static void
gsettings_description (void)
{
const gchar *description;
description = g_settings_schema_key_get_description (global_schema_key);
g_print ("%s\n", description);
}
static void static void
gsettings_range (void) gsettings_range (void)
{ {
@ -562,6 +570,12 @@ gsettings_help (gboolean requested,
synopsis = N_("SCHEMA[:PATH] KEY"); synopsis = N_("SCHEMA[:PATH] KEY");
} }
else if (strcmp (command, "describe") == 0)
{
description = _("Query the description for KEY");
synopsis = N_("SCHEMA[:PATH] KEY");
}
else if (strcmp (command, "set") == 0) else if (strcmp (command, "set") == 0)
{ {
description = _("Set the value of KEY to VALUE"); description = _("Set the value of KEY to VALUE");
@ -615,6 +629,7 @@ gsettings_help (gboolean requested,
" list-children List children of a schema\n" " list-children List children of a schema\n"
" list-recursively List keys and values, recursively\n" " list-recursively List keys and values, recursively\n"
" range Queries the range of a key\n" " range Queries the range of a key\n"
" describe Queries the description of a key\n"
" get Get the value of a key\n" " get Get the value of a key\n"
" set Set the value of a key\n" " set Set the value of a key\n"
" reset Reset the value of a key\n" " reset Reset the value of a key\n"
@ -752,6 +767,12 @@ main (int argc, char **argv)
else if ((argc == 2 || argc == 3) && strcmp (argv[1], "list-recursively") == 0) else if ((argc == 2 || argc == 3) && strcmp (argv[1], "list-recursively") == 0)
function = gsettings_list_recursively; function = gsettings_list_recursively;
else if (argc == 4 && strcmp (argv[1], "describe") == 0)
{
need_settings = FALSE;
function = gsettings_description;
}
else if (argc == 4 && strcmp (argv[1], "range") == 0) else if (argc == 4 && strcmp (argv[1], "range") == 0)
{ {
need_settings = FALSE; need_settings = FALSE;