Skip to content

Commit

Permalink
chore: update error message in install script
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Chiang <[email protected]>
  • Loading branch information
charlie0129 committed Sep 28, 2023
1 parent ac86188 commit 5c420ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
7 changes: 5 additions & 2 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,13 @@ One thing to note: this option is purely cosmetic. batt will still function even
}

func bool2Text(b bool) string {
var c string
if b {
return color.New(color.Bold, color.FgGreen).Sprint("✔")
c = "✔"
} else {
c = "✘"
}
return bold("✘")
return bold(c)
}

func bold(format string, a ...interface{}) string {
Expand Down
18 changes: 6 additions & 12 deletions hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ confirm() {
echo -n "$1 [y/n]: "
read -r -n 1 REPLY
case $REPLY in
[y])
[yY])
echo
return 0
;;
[n])
[nN])
echo
return 1
;;
[Y])
echo
return 0
;;
[N])
echo
return 1
;;
*) printf "invalid input" ;;
*) printf " is invalid. Press 'y' to continue; 'n' to exit. \n" ;;
esac
done
}
Expand All @@ -43,6 +35,8 @@ launch_daemon="/Library/LaunchDaemons/cc.chlc.batt.plist"

# Uninstall old versions (if present)
if [[ -f "$launch_daemon" ]]; then
echo "You have old versions of batt installed, which need to be uninstalled before installing the latest version. We will uninstall it for you now."
confirm "Is this OK?" || exit 0
info "Stopping old versions of batt..."
sudo launchctl unload "$launch_daemon"
sudo rm -f "$launch_daemon"
Expand Down Expand Up @@ -70,7 +64,7 @@ if [[ -z "$PREFIX" ]]; then
fi

echo "Will install batt ${version} to $PREFIX (to change install location, set \$PREFIX environment variable)."
confirm "Continue?" || exit 0
confirm "Ready to install?" || exit 0
info "Downloading batt ${version} from $tarball_url and installing to $PREFIX..."
sudo mkdir -p "$PREFIX"
curl -fsSL "$tarball_url" | sudo tar -xzC "$PREFIX"
Expand Down

0 comments on commit 5c420ae

Please sign in to comment.