commit 70fdbf205a7520ecd885534adcea539b05e587d6 parent 863e2f8105695f9c39ce76b3cae25efd478df3da Author: Ayush Agarwal <ayush@fastmail.in> Date: Sun, 14 Nov 2021 13:56:55 +0530 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 Diffstat:
| M | tessen | | | 30 | ++++++++++++++++++------------ |
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git 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