From c1976347bcc4b066715a0eb60b1525d5215c0770 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Fri, 21 Aug 2015 18:54:12 +0200 Subject: clean up addpass script --- addpass | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/addpass b/addpass index 0b74c72..5b2ec20 100755 --- a/addpass +++ b/addpass @@ -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 " 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}" -- cgit