summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyush Agarwal <ayush@fastmail.in>2021-11-14 13:56:55 +0530
committerAyush Agarwal <ayush@fastmail.in>2021-11-14 13:56:55 +0530
commit70fdbf205a7520ecd885534adcea539b05e587d6 (patch)
tree5b0ca55f54b572c22e2f07f0c7b6dd6c1cbae8c8
parent863e2f8105695f9c39ce76b3cae25efd478df3da (diff)
refactor: change the 2nd and 3rd menu
Use the environment variables to show options for autotype and username. The URL should also be accounted for and the 3rd menu should show 'open' instead of 'autotype'. feat: continue to implement features explained in 9511148
-rwxr-xr-xtessen30
1 files changed, 18 insertions, 12 deletions
diff --git a/tessen b/tessen
index 61b2cea..ee0a5ff 100755
--- a/tessen
+++ b/tessen
@@ -94,25 +94,31 @@ get_pass_data() {
fi
}
-# get the key that the user will choose to autotype or copy
+# SECOND MENU: show a list of possible keys to choose from for auto typing or
+# copying
+# THIRD MENU: optional, this will show up if TESSEN_ACTION is blank
get_key() {
local -a key_arr
local ch flag=false
- if [[ "$1" == "pass_key_list" ]]; then
- key_arr=("autotype username and password" "username" "password" "${!tsn_passdata[@]}")
- shift
- elif [[ "$1" == "opt_key_list" ]]; then
- key_arr=("autotype" "copy")
- shift
- else
- exit 1
+ # the second menu
+ if [[ "$1" == "key_list" ]]; then
+ if [[ "$tsn_otp" == "true" ]]; then
+ key_arr=("$tsn_autokey" "$tsn_userkey" "password" "otp" "${!tsn_passdata[@]}")
+ else
+ key_arr=("$tsn_autokey" "$tsn_userkey" "password" "${!tsn_passdata[@]}")
+ fi
+ # the (optional) third menu, depends on $tsn_action
+ elif [[ "$1" == "option" ]]; then
+ key_arr=("$tsn_autokey" "copy")
+ elif [[ "$1" == "$tsn_urlkey" ]]; then
+ key_arr=("open" "copy")
fi
- # a dynamically scoped variable to hold the key selection for key_menu
- chosen_key="$(printf '%s\n' "${key_arr[@]}" | "$tsn_backend" "$tsn_backend_opts")"
+ # a dynamically scoped variable to hold the selected key for key_menu
+ chosen_key="$(printf "%s\n" "${key_arr[@]}" | "$tsn_backend" "$tsn_backend_opts")"
- # validate the chosen key name
+ # validate the chosen key, if it doesn't exist, exit
for ch in "${key_arr[@]}"; do
if [[ "$chosen_key" == "$ch" ]]; then
flag=true