summaryrefslogtreecommitdiff
path: root/lib/keyringer/actions/preferences
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keyringer/actions/preferences')
-rwxr-xr-xlib/keyringer/actions/preferences37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/keyringer/actions/preferences b/lib/keyringer/actions/preferences
new file mode 100755
index 0000000..e82848d
--- /dev/null
+++ b/lib/keyringer/actions/preferences
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Manipulate preferences.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+COMMAND="$2"
+
+if [ -z "$COMMAND" ]; then
+ echo "Usage: keyringer <keyring> preferences <command> [arguments]"
+ echo "Available commands:"
+ echo " ls"
+ echo " edit"
+ echo " add"
+ exit 1
+fi
+
+# Create options file if old repository
+if [ ! -e "$PREFERENCES" ]; then
+ echo "Creating preferences file..."
+ touch "$PREFERENCES"
+fi
+
+if [ "$COMMAND" == "ls" ]; then
+ cat "$PREFERENCES"
+elif [ "$COMMAND" == "edit" ]; then
+ "$EDITOR" "$PREFERENCES"
+elif [ "$COMMAND" == "add" ]; then
+ shift 2
+ [[ -n $* ]] && echo $* >> "$PREFERENCES"
+else
+ printf "%s: No such command %s\n" "$BASENAME" "$COMMAND"
+ exit 1
+fi