From 4828988474a20471d4fc2290eb15c6460f672e19 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sun, 21 Apr 2019 21:46:59 -0400 Subject: dude more stuff --- bin/mw | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/mw b/bin/mw index 8462d8b..055be6a 100755 --- a/bin/mw +++ b/bin/mw @@ -213,8 +213,11 @@ confirm() { printf "Do you want to to %s? [y/N]\\n\t" "$@" && read -r input && ! printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "^y$\|^yes$" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 return 0 ;} -pick() { numbered="$(find "$accdir" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | nl)" - [ "$(echo "$numbered" | wc -w)" = 0 ] && printf "No accounts to choose from.\\n" && return 1 +list() { numbered="$(find "$accdir" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" 2>/dev/null | nl)" + [ "$(echo "$numbered" | wc -w)" = 0 ] && printf "No configured accounts.\\n" && return 1 +} + +pick() { list printf "Select an accounts to %s:\\n" "$1" echo "$numbered" printf "\033[36m\t" @@ -263,19 +266,34 @@ asktype() { while : ; do init() { \ echo "Initializing a mutt-wizard configuration..." - [ -f "$muttdir/muttrc" ] && echo "There is already a preexisting config." && return 1 + [ -f "$muttdir/muttrc" ] && echo "There is already a preexisting config. Purge the previous to reinit." && return 1 + mkdir -p "$muttdir" "$accdir" cp -v "$muttshare/mailcap" "$muttdir" cp -v "$muttshare/muttrc" "$muttdir" } + case "$1" in init) init ;; - new) asktype && askinfo && tryconnect && finalize ;; - passedit) pick "change the password of" && confirm "change \`$title\`'s password" && getpass ;; + ls) list ;; + add) asktype && askinfo && tryconnect && finalize ;; + pass) pick "change the password of" && getpass ;; delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; purge) confirm "delete all account data" && rm -rf "$mbsyncrc" "$accdir" "$muttdir/personal.muttrc" && echo "All configs and account settings have been purged." ;; cron) choosecron ;; - *) printf "Invalid input.\\n" + *) cat << EOF +mw: mutt-wizard, auto-configure email accounts for mutt +and + +Allowed options: + init Run once and first to copy required files + add Add and autoconfigure an email address (9 max.) + ls List configured accounts + delete Pick an account to delete + purge Delete all accounts and settings + cron Enable or disable an autosync via cronjob + all else Print this message +EOF esac rm -rf "$tmpdir" -- cgit v1.2.3