clean up addpass script

This commit is contained in:
Rasmus Steinke 2015-08-21 18:54:12 +02:00
parent 6593af1cf1
commit c1976347bc

22
addpass
View File

@ -2,7 +2,7 @@
source $HOME/.config/rofi-pass/config source $HOME/.config/rofi-pass/config
if [[ -n "$2" && "$1" == "--root" ]]; then if [[ -n "$3" && "$2" == "--root" ]]; then
root="${2}" root="${2}"
elif [[ -n $root ]]; then elif [[ -n $root ]]; then
root=$root root=$root
@ -12,25 +12,24 @@ else
root="$HOME/.password-store" root="$HOME/.password-store"
fi fi
Name="$2"
if [[ $1 == "--help" || $1 == "=h" ]]; then if [[ $1 == "--help" || $1 == "=h" ]]; then
echo "add pass files for rofi-pass" echo "add pass files for rofi-pass"
echo "(C) 2015 Rasmus Steinke <rasi at xssn dot at>" echo "(C) 2015 Rasmus Steinke <rasi at xssn dot at>"
echo "" echo ""
echo "--root \"foobar\" Absolute path to password store" echo "--name \"foobar\" Mandatory first argument - filename of password file"
echo " Needs to be first option." echo "--root \"foobar\" Optional second argument - Absolute path to password store"
echo " Leave empty to use top level)"
echo "" echo ""
echo "+name \"foobar\" Needed field - filename of password file" echo "+FIELD \"barbaz\" Every field name has to start with \"+\""
echo "" echo " Values should be quoted"
echo " Every field name has to start with \"-\""
echo " Values should be quoted"
echo "" echo ""
echo "Example:" echo "Example:"
echo "adduser --root private +user \"Richard\" +foo \"bar\" +autotype \"foo :tab user :tab pass\"" echo "adduser --name \"my password file\" --root \"$HOME/passwords\" +user \"Richard\" +foo \"bar\" +autotype \"foo :tab user :tab pass\""
exit exit
else else
if [[ $* != *"-name "* ]]; then if [[ $* != *"--name "* ]]; then
echo "Missing +name option. Try --help" echo "Missing --name option. Try --help"
exit exit
fi fi
fi fi
@ -42,7 +41,6 @@ IFS="+";
fields="$@"; fields="$@";
fieldsArray=($fields); fieldsArray=($fields);
Name=$(printf '%s\n' "${fieldsArray[@]}" | grep "name " | cut -d ' ' -f 2- | sed -e 's/[[:blank:]]\+$//')
read -p "Enter password for entry \"${Name}\" > " -s pass read -p "Enter password for entry \"${Name}\" > " -s pass
cd "${root}" cd "${root}"