diff options
author | Rasmus Steinke <rasi@xssn.at> | 2015-08-21 18:54:12 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2015-08-21 18:54:12 +0200 |
commit | c1976347bcc4b066715a0eb60b1525d5215c0770 (patch) | |
tree | bf2046cb955b65e3305ab3291273b3fb97078e9b | |
parent | 6593af1cf1202ecdfe8c1b2a08e0aa9a7b2f129f (diff) | |
download | rofi-pass-c1976347bcc4b066715a0eb60b1525d5215c0770.tar.gz |
clean up addpass script
-rwxr-xr-x | addpass | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -2,7 +2,7 @@ source $HOME/.config/rofi-pass/config -if [[ -n "$2" && "$1" == "--root" ]]; then +if [[ -n "$3" && "$2" == "--root" ]]; then root="${2}" elif [[ -n $root ]]; then root=$root @@ -12,25 +12,24 @@ else root="$HOME/.password-store" fi +Name="$2" + if [[ $1 == "--help" || $1 == "=h" ]]; then echo "add pass files for rofi-pass" echo "(C) 2015 Rasmus Steinke <rasi at xssn dot at>" echo "" - echo "--root \"foobar\" Absolute path to password store" - echo " Needs to be first option." - echo " Leave empty to use top level)" - echo "" - echo "+name \"foobar\" Needed field - filename of password file" + echo "--name \"foobar\" Mandatory first argument - filename of password file" + echo "--root \"foobar\" Optional second argument - Absolute path to password store" echo "" - echo " Every field name has to start with \"-\"" - echo " Values should be quoted" + echo "+FIELD \"barbaz\" Every field name has to start with \"+\"" + echo " Values should be quoted" echo "" 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 else - if [[ $* != *"-name "* ]]; then - echo "Missing +name option. Try --help" + if [[ $* != *"--name "* ]]; then + echo "Missing --name option. Try --help" exit fi fi @@ -42,7 +41,6 @@ IFS="+"; 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 cd "${root}" |