Skip to content

Commit

Permalink
handle no-tty case in gum_func with our old/better error (#115)
Browse files Browse the repository at this point in the history
* handle no-tty case in gum_func

* good error message

* cleanup
  • Loading branch information
jhheider authored Jan 14, 2023
1 parent 5ae1479 commit 51a497d
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,6 @@ prepare() {
fi
}

gum_no_tty() {
cmd="$1"
while test "$1" != -- -a -n "$1"; do
shift
done
if test -n "$1"; then shift; fi # remove the --
case "$cmd" in
format|style)
echo "$@";;
confirm)
if test -n "$TEA_YES"; then
echo "tea: error: no tty detected, re-run with \`YES=1\` set" >&2
return 1
fi;;
*)
"$@";;
esac
}

get_gum() {
if command -v gum >/dev/null 2>&1; then
TEA_GUM=gum
Expand Down Expand Up @@ -218,6 +199,9 @@ gum_func() {
$TEA_GUM "$@" --timeout=1ms --default=yes
set -e
return 0
elif test ! -t 1; then
echo "tea: error: no tty detected, re-run with \`TEA_YES=1\` set" >&2
return 1
fi;;
spin)
if test ! -t 1; then
Expand Down

0 comments on commit 51a497d

Please sign in to comment.