diff options
author | Luke Smith <luke@lukesmith.xyz> | 2019-04-21 21:46:59 -0400 |
---|---|---|
committer | Luke Smith <luke@lukesmith.xyz> | 2019-04-21 21:46:59 -0400 |
commit | 4828988474a20471d4fc2290eb15c6460f672e19 (patch) | |
tree | 603a7c9e2c7dcd485d9157110daebe1fcba7312d /bin | |
parent | 04462ceb46a8a0b287bde4547b38444847bfdc54 (diff) |
dude more stuff
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mw | 30 |
1 files changed, 24 insertions, 6 deletions
@@ -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" |