summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-05-09 14:42:33 +0200
committerRyan Lortie <desrt@desrt.ca>2011-05-09 14:42:33 +0200
commit8a7c838d9d574dfe16722154ff7e5842cae795e1 (patch)
tree3170475a156c5df92855ded1b01a43598c4acf2f
parent476032d3b8eadd6197d75f78797fd626e9551357 (diff)
downloaddconf-8a7c838d9d574dfe16722154ff7e5842cae795e1.tar.gz
Add 'dconf reset'.
-rw-r--r--bin/dconf-bash-completion.sh14
-rw-r--r--bin/dconf.vala28
2 files changed, 39 insertions, 3 deletions
diff --git a/bin/dconf-bash-completion.sh b/bin/dconf-bash-completion.sh
index fc1e7aa..46d732d 100644
--- a/bin/dconf-bash-completion.sh
+++ b/bin/dconf-bash-completion.sh
@@ -9,22 +9,30 @@ __dconf() {
case "${COMP_CWORD}" in
1)
- choices=$'help \nread \nlist \nwrite \nupdate \nlock \nunlock \nwatch '
+ choices=$'help \nread \nlist \nwrite \nreset\n update \nlock \nunlock \nwatch '
;;
2)
case "${COMP_WORDS[1]}" in
help)
- choices=$'help \nread \nlist \nwrite \nupdate \nlock \nunlock \nwatch '
+ choices=$'help \nread \nlist \nwrite \nreset\n update \nlock \nunlock \nwatch '
;;
list)
choices="$(dconf _complete / "${COMP_WORDS[2]}")"
;;
- read|list|write|lock|unlock|watch)
+ read|list|write|lock|unlock|watch|reset)
choices="$(dconf _complete '' "${COMP_WORDS[2]}")"
;;
esac
;;
+
+ 3)
+ case "${COMP_WORDS[1]} ${COMP_WORDS[2]}" in
+ reset\ -f)
+ choices="$(dconf _complete '' "${COMP_WORDS[3]}")"
+ ;;
+ esac
+ ;;
esac
local IFS=$'\n'
diff --git a/bin/dconf.vala b/bin/dconf.vala
index b6dc649..a2d7a60 100644
--- a/bin/dconf.vala
+++ b/bin/dconf.vala
@@ -49,6 +49,11 @@ void show_help (bool requested, string? command) {
synopsis = "KEY VALUE";
break;
+ case "reset":
+ description = "Reset a key or dir. -f is required for dirs.";
+ synopsis = "[-f] PATH";
+ break;
+
case "update":
description = "Update the system dconf databases";
synopsis = "";
@@ -85,6 +90,7 @@ Commands:
read Read the value of a key
list List the contents of a dir
write Change the value of a key
+ reset Reset the value of a key or dir
update Update the system databases
lock Set a lock on a path
unlock Clear a lock on a path
@@ -170,6 +176,27 @@ void dconf_write (string?[] args) throws Error {
client.write (key, Variant.parse (null, val));
}
+void dconf_reset (string?[] args) throws Error {
+ var client = new DConf.Client ();
+ bool force = false;
+ var index = 2;
+
+ if (args[index] == "-f") {
+ force = true;
+ index++;
+ }
+
+ var path = args[index];
+
+ DConf.verify_path (path);
+
+ if (DConf.is_dir (path) && !force) {
+ throw new OptionError.FAILED ("-f must be given to (recursively) reset entire dirs");
+ }
+
+ client.write (path, null);
+}
+
void dconf_lock (string?[] args) throws Error {
var client = new DConf.Client ();
var key = args[2];
@@ -249,6 +276,7 @@ int main (string[] args) {
CommandMapping ("read", dconf_read),
CommandMapping ("list", dconf_list),
CommandMapping ("write", dconf_write),
+ CommandMapping ("reset", dconf_reset),
CommandMapping ("update", dconf_update),
CommandMapping ("lock", dconf_lock),
CommandMapping ("unlock", dconf_unlock),