]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Move the 'preferences' action to a separate file
authorricola <ricola@poivron.org>
Fri, 19 Oct 2012 20:09:00 +0000 (22:09 +0200)
committerricola <ricola@poivron.org>
Fri, 19 Oct 2012 20:10:22 +0000 (22:10 +0200)
keyringer
share/keyringer/preferences [new file with mode: 0755]

index a59fd2f93cd0edaff2ebbb2266546da8dc47d6bc..0f6372c33ad1525c581dcc482f5640f64ded08cd 100755 (executable)
--- a/keyringer
+++ b/keyringer
@@ -104,33 +104,6 @@ function keyringer_dispatch {
   fi
 }
 
-function keyringer_preferences {
-  COMMAND="$3"
-
-  if [ -z "$COMMAND" ]; then
-    echo "Usage: keyringer <keyring> `basename $0` <command> [arguments]"
-    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 3
-    echo $* >> "$PREFERENCES"
-  else
-    printf "%s: No such command %s\n" "$BASENAME" "$COMMAND"
-    exit 1
-  fi
-}
-
 # Config
 NAME="keyringer"
 KEYRINGER_VERSION="0.1"
@@ -176,8 +149,6 @@ fi
 
 if [ "$ACTION" == "init" ]; then
   keyringer_init $*
-elif [ "$ACTION" == "preferences" ]; then
-  keyringer_preferences $*
 elif keyringer_has_action "$ACTION"; then
   keyringer_dispatch $*
 else
diff --git a/share/keyringer/preferences b/share/keyringer/preferences
new file mode 100755 (executable)
index 0000000..65b38f3
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Manipulate preferences.
+#
+
+# Load functions
+LIB="`dirname $0`/../../lib/keyringer/functions"
+source "$LIB" || exit 1
+
+COMMAND="$2"
+
+if [ -z "$COMMAND" ]; then
+  echo "Usage: keyringer <keyring> $ACTION <command> [arguments]"
+  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
+else
+  printf "%s: No such command %s\n" "$BASENAME" "$COMMAND"
+  exit 1
+fi