]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Adding mv and rmdir actions
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 27 Dec 2013 01:56:30 +0000 (23:56 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 27 Dec 2013 01:56:30 +0000 (23:56 -0200)
ChangeLog
lib/keyringer/actions/mv [new file with mode: 0755]
lib/keyringer/actions/rmdir [new file with mode: 0755]
share/man/keyringer.1.mdwn

index eb6b543a4c60ae68a2915e0810ef21d9678563e1..401fc645667674f47364356cd08e72c39d0401e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,12 @@
 2013-12-26 - Silvio Rhatto  <rhatto@riseup.net>
 
-       New action: find.
+       New actions: find, mv, rmdir
+
+       Support for RELATIVE_FOLDER at git action
 
 2013-12-10 - Silvio Rhatto  <rhatto@riseup.net>
 
-       New actions: shell (#34), help, mkdir, teardown.
+       New actions: shell (#34), help, mkdir, teardown
 
 2013-11-26 - 0.2.9 Silvio Rhatto  <rhatto@riseup.net>
 
diff --git a/lib/keyringer/actions/mv b/lib/keyringer/actions/mv
new file mode 100755 (executable)
index 0000000..aaf6772
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Move secrets.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+# Avoid leading slash
+ORIG="$(keyringer_filename `echo "$2" | sed -e "s|^/*||"`)"
+DEST="`echo "$3" | sed -e "s|^/*||"`"
+
+# Set destination
+if [ ! -d "$KEYDIR/$RELATIVE_PATH/$DEST" ]; then
+  keyringer_get_new_file $DEST
+else
+  FILE="$DEST"
+fi
+
+# Check if secret exists
+if ! echo "$ORIG" | grep -q '*' && [ ! -e "$KEYDIR/$RELATIVE_PATH/$ORIG" ]; then
+  echo "Secret not found: $ORIG"
+  exit 1
+fi
+
+# Run move command
+keyringer_exec git "$BASEDIR" mv $ORIG $FILE
diff --git a/lib/keyringer/actions/rmdir b/lib/keyringer/actions/rmdir
new file mode 100755 (executable)
index 0000000..398cf11
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Remove folders.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+# Aditional parameters
+CWD="`pwd`"
+
+# Avoid leading slash
+shift
+ARGS="`echo "$*" | sed -e "s|^/*||"`"
+
+# Run rmdir command
+cd "$KEYDIR/$RELATIVE_PATH" && rmdir $ARGS
+cd "$CWD"
index c3a8a7ca965d65e6e7d4c19150bc17805a5b2400..1cd7a45e8cc16d260d6d287d06f1ddab6d1db1b4 100644 (file)
@@ -62,6 +62,9 @@ ls <*path*>
 mkdir <*path*>
 :   Create a directory inside the repository *keys* folder.
 
+:rmdir <*path*>
+:   Remove an empty folder inside the repository *keys* folder.
+
 tree <*path*>
 :   List contents from the toplevel repository *keys* folder or from relative paths
     if *path* is specified using a tree-like format. Like the ls wrapper, this is a
@@ -116,6 +119,9 @@ del <*secret*>
 rm <*secret*>
 :   Alias for *del* action.
 
+mv <*secret*> <*dest*>
+:   Rename a secret.
+
 edit <*secret*>
 :   Edit a secret by temporarily decrypting it, opening the decrypted copy into the 
     text editor defined by the *$EDITOR* environment variable and then re-encrypting it.