tessen

default description
git clone https://git.awy.one/tessen.git
Log | Files | Refs | README | LICENSE

commit cd4608e31b3f4f42891c69e64c7b5f78ca507ff3
parent 3239d30b10cf4162f23a58e78513818682c68638
Author: Ayush Agarwal <ayush@fastmail.in>
Date:   Wed, 16 Feb 2022 22:27:10 +0530

refactor: better response when validating action

with this change, an action can't be selected if it's not possible and
the best available choice should be selected automatically in case no
action is provided.

Diffstat:
Mtessen | 37+++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/tessen b/tessen @@ -594,10 +594,39 @@ validate_cliptime() { validate_action() { case "$1" in - autotype) readonly tsn_action="autotype" ;; - copy) readonly tsn_action="copy" ;; - both) readonly tsn_action="both" ;; - "") readonly tsn_action="" ;; + autotype) + if ! is_installed "wtype"; then + _die "wtype is not installed, unable to autotype pass data" + fi + tsn_action="autotype" + ;; + copy) + if ! is_installed "wl-copy"; then + _die "wl-clipboard is not installed, unable to copy-paste pass data" + fi + tsn_action="copy" + ;; + both) + if ! is_installed "wtype"; then + _die "wtype is not installed, unable to autotype pass data" + elif ! is_installed "wl-copy"; then + _die "wl-clipboard is not installed, unable to copy-paste pass data" + fi + tsn_action="both" + ;; + default) + if is_installed "wtype" && is_installed "wl-copy"; then + tsn_action="default" + elif is_installed "wtype" && ! is_installed "wl-copy"; then + printf "%s\n" "wl-clipboard is not installed, unable to copy-paste pass data" >&2 + tsn_action="autotype" + elif ! is_installed "wtype" && is_installed "wl-copy"; then + printf "%s\n" "wtype is not installed, unable to autotype pass data" >&2 + tsn_action="copy" + elif ! is_installed "wtype" && ! is_installed "wl-copy"; then + _die "please install at least one the following backends to use tessen: wtype | wl-clipboard " + fi + ;; *) _die "please specify a valid action: autotype | copy | both" ;; esac }