about summary refs log tree commit diff stats
path: root/ayu
diff options
context:
space:
mode:
authorNova [ミラーワールド] <novaburst@kalli.st>2021-12-09 11:43:43 +0000
committerNova [ミラーワールド] <novaburst@kalli.st>2021-12-09 11:43:43 +0000
commit633b333738406c99f157f23d4ee88bae8cd7350f (patch)
tree54cfe632fbf281ab12a76fae863a0056a252594c /ayu
parent14bca3da7f908d341cc4392d49f53deeaa32fe3e (diff)
downloadayu-633b333738406c99f157f23d4ee88bae8cd7350f.tar.gz
1 Dir(s) 70,368,744,161,280 bytes free
Diffstat (limited to 'ayu')
-rwxr-xr-xayu22
1 files changed, 15 insertions, 7 deletions
diff --git a/ayu b/ayu
index 8bcfb43..ccee4cb 100755
--- a/ayu
+++ b/ayu
@@ -14,17 +14,17 @@ ayu_pub="$ayu_store/.age-id"
 
 EDITOR=${EDITOR:-vi}
 
+# Run some tests
 test -d $ayu_dir || mkdir -p $ayu_dir
 test -d $ayu_store || mkdir -p $ayu_store
 
-if ! [ -f $ayu_key ];then
-	printf "First generate your own age(1) key with age-keygen(1) and place it as $ayu_key. \n"
-	printf "e.g: age-keygen -o $ayu_key and public key should be on $ayu_pub \n"
-	exit 1
-fi
+test -f $ayu_key || printf "$0: Generate your own age(1) key with age-keygen(1) and place it as a $ayu_key. \n"
+test -f $ayu_pub || printf "$0: Public key needs to be placed on $ayu_pub (Hint: it's the visible output of age-keygen(1)) \n"
 
+# Switch directory to the password store, otherwise bail out.
 cd $ayu_store || exit 1
 
+# Edit an entry if it exists
 edit() {
 	age --decrypt --identity=$ayu_key --output=${1%%.age} ${1%%.age}.age
 	${EDITOR} ${1%%.age}
@@ -32,10 +32,12 @@ edit() {
 	rm ${1%%.age}
 }
 
+# List contents of the store
 list() {
 	tree $ayu_store
 }
 
+# Create a new entry
 new() {
 	test -d "$1" && usage && exit
 
@@ -48,14 +50,19 @@ new() {
 	mv $tmpfile.age "${1%%.age}".age
 	rm $tmpfile
 }
+
+# Delete an entry
 remove() {
 	test -d "$1" && usage && exit
 	rm -r "$(dirname "$1")"
 }
+
+# Print usage
 usage() {
-	printf "$0 [ edit | list | new | rm | usage | view ] \n"
+	printf "$0 [ ed | ls | new | rm | vi ] \n"
 }
 
+# View an entry, otherwise list the contents of the directory specified.
 view() {
 	if [ -f "${1%%.age}".age ];then
 		age --decrypt --identity=$ayu_key "${1%%.age}".age
@@ -66,6 +73,7 @@ view() {
 		exit
 	fi
 }
+
 case $1 in
 	edit | ed)
 		edit $2
@@ -82,7 +90,7 @@ case $1 in
 	usage)
 		usage
 		;;
-	view)
+	view | vi)
 		view $2
 		;;
 	*)