mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
Improve install.sh output and prompt to run setup wizard
Redirect all UI output to stderr so piped installs work cleanly. Add Fabro header, color enhancements, and checkmark/cross indicators. Prompt interactive users to run `arc install` immediately after download. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5b71f42994
commit
d5defaf2bd
1 changed files with 32 additions and 12 deletions
44
install.sh
44
install.sh
|
|
@ -3,26 +3,35 @@ set -eu
|
|||
|
||||
REPO="brynary/arc"
|
||||
|
||||
# Colors (only when stdout is a terminal)
|
||||
if [ -t 1 ]; then
|
||||
# Colors (only when stderr is a terminal)
|
||||
if [ -t 2 ]; then
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
DIM='\033[2m'
|
||||
BOLD='\033[1m'
|
||||
BOLD_CYAN='\033[1;36m'
|
||||
RESET='\033[0m'
|
||||
else
|
||||
RED=''
|
||||
GREEN=''
|
||||
DIM=''
|
||||
BOLD=''
|
||||
BOLD_CYAN=''
|
||||
RESET=''
|
||||
fi
|
||||
|
||||
info() { printf "${BOLD}%s${RESET}\n" "$1"; }
|
||||
success() { printf "${GREEN}%s${RESET}\n" "$1"; }
|
||||
error() { printf "${RED}error: %s${RESET}\n" "$1" >&2; exit 1; }
|
||||
info() { printf " %s\n" "$1" >&2; }
|
||||
step() { printf " ${BOLD}%s${RESET}\n" "$1" >&2; }
|
||||
dim() { printf " ${DIM}%s${RESET}\n" "$1" >&2; }
|
||||
success() { printf " ${GREEN}✔${RESET} %s\n" "$1" >&2; }
|
||||
error() { printf " ${RED}✗ %s${RESET}\n" "$1" >&2; exit 1; }
|
||||
|
||||
# --- Header ---
|
||||
printf "\n ⚒️ ${BOLD}Fabro Install${RESET}\n\n" >&2
|
||||
|
||||
# --- Require gh CLI ---
|
||||
if ! command -v gh >/dev/null 2>&1; then
|
||||
error "gh CLI is required but not installed. Install it from https://cli.github.com"
|
||||
error "gh CLI is required but not installed. Install it from ${BOLD_CYAN}https://cli.github.com${RESET}"
|
||||
fi
|
||||
|
||||
# --- Detect platform ---
|
||||
|
|
@ -57,10 +66,10 @@ ASSET="arc-${TARGET}.tar.gz"
|
|||
TMPDIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
|
||||
info "Downloading latest Arc release for ${TARGET}..."
|
||||
dim "Downloading arc for ${TARGET}..."
|
||||
gh release download --repo "$REPO" --pattern "$ASSET" --dir "$TMPDIR" --clobber
|
||||
|
||||
info "Extracting..."
|
||||
dim "Extracting..."
|
||||
tar xzf "${TMPDIR}/${ASSET}" -C "$TMPDIR"
|
||||
|
||||
# --- Install binary ---
|
||||
|
|
@ -69,7 +78,7 @@ INSTALL_DIR="${ARC_INSTALL_DIR:-/usr/local/bin}"
|
|||
if [ -w "$INSTALL_DIR" ]; then
|
||||
mv "${TMPDIR}/arc-${TARGET}/arc" "${INSTALL_DIR}/arc"
|
||||
else
|
||||
info "Installing to ${INSTALL_DIR} (requires sudo)..."
|
||||
dim "Installing to ${INSTALL_DIR} (requires sudo)..."
|
||||
sudo mv "${TMPDIR}/arc-${TARGET}/arc" "${INSTALL_DIR}/arc"
|
||||
fi
|
||||
|
||||
|
|
@ -81,6 +90,17 @@ if [ -z "$VERSION" ]; then
|
|||
error "Installation failed: could not run arc --version"
|
||||
fi
|
||||
|
||||
success "Successfully installed ${VERSION} to ${INSTALL_DIR}/arc"
|
||||
echo ""
|
||||
info "Run 'arc install' to complete setup."
|
||||
success "Installed ${VERSION} to ${BOLD_CYAN}${INSTALL_DIR}/arc${RESET}"
|
||||
echo "" >&2
|
||||
|
||||
# --- Prompt to run setup wizard ---
|
||||
if [ -t 0 ] && [ -t 2 ]; then
|
||||
printf " ${BOLD}Run ${BOLD_CYAN}arc install${RESET}${BOLD} now to complete setup? [Y/n]${RESET} " >&2
|
||||
read -r answer </dev/tty
|
||||
case "$answer" in
|
||||
[nN]*) dim "Skipping. Run ${BOLD_CYAN}arc install${RESET}${DIM} whenever you're ready." ;;
|
||||
*) echo "" >&2; exec "${INSTALL_DIR}/arc" install ;;
|
||||
esac
|
||||
else
|
||||
info "Run ${BOLD_CYAN}arc install${RESET} to complete setup."
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue