1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:04:42 +00:00

🎨 simplify

This commit is contained in:
Tw93
2025-10-04 09:09:12 +08:00
parent 511c77b3c4
commit c1b4bb33a9
2 changed files with 12 additions and 17 deletions

View File

@@ -171,11 +171,11 @@ check_requirements() {
# Check if already installed via Homebrew # Check if already installed via Homebrew
if command -v brew >/dev/null 2>&1 && brew list mole >/dev/null 2>&1; then if command -v brew >/dev/null 2>&1 && brew list mole >/dev/null 2>&1; then
log_warning "Mole is already installed via Homebrew" echo -e "${YELLOW}Mole is installed via Homebrew${NC}"
echo "" echo ""
echo "Please choose one installation method:" echo "Choose one:"
echo " 1. Keep Homebrew version (recommended): brew upgrade mole" echo " 1. Update via Homebrew: ${GREEN}brew upgrade mole${NC}"
echo " 2. Switch to manual install: brew uninstall mole && then re-run this script" echo " 2. Switch to manual: ${GREEN}brew uninstall mole${NC} then re-run this"
echo "" echo ""
exit 1 exit 1
fi fi

21
mole
View File

@@ -141,11 +141,7 @@ show_help() {
update_mole() { update_mole() {
# Check if installed via Homebrew # Check if installed via Homebrew
if command -v brew >/dev/null 2>&1 && brew list mole >/dev/null 2>&1; then if command -v brew >/dev/null 2>&1 && brew list mole >/dev/null 2>&1; then
echo -e "${YELLOW}Mole is installed via Homebrew${NC}" echo -e "${GREEN}Homebrew detected, use: ${BLUE}brew upgrade mole${NC}"
echo ""
echo "Please use Homebrew to update:"
echo -e " ${GREEN}brew upgrade mole${NC}"
echo ""
exit 0 exit 0
fi fi
@@ -159,18 +155,18 @@ update_mole() {
if command -v curl >/dev/null 2>&1; then if command -v curl >/dev/null 2>&1; then
if ! curl -fsSL --connect-timeout 10 --max-time 60 "$installer_url" -o "$tmp_installer"; then if ! curl -fsSL --connect-timeout 10 --max-time 60 "$installer_url" -o "$tmp_installer"; then
rm -f "$tmp_installer" rm -f "$tmp_installer"
log_error "Failed to download installer (network timeout or error)" log_error "Failed to download installer"
exit 1 exit 1
fi fi
elif command -v wget >/dev/null 2>&1; then elif command -v wget >/dev/null 2>&1; then
if ! wget --timeout=10 --tries=3 -qO "$tmp_installer" "$installer_url"; then if ! wget --timeout=10 --tries=3 -qO "$tmp_installer" "$installer_url"; then
rm -f "$tmp_installer" rm -f "$tmp_installer"
log_error "Failed to download installer (network timeout or error)" log_error "Failed to download installer"
exit 1 exit 1
fi fi
else else
rm -f "$tmp_installer" rm -f "$tmp_installer"
log_error "Please install curl or wget to update Mole" log_error "curl or wget required"
exit 1 exit 1
fi fi
@@ -182,13 +178,12 @@ update_mole() {
local install_dir local install_dir
install_dir="$(cd "$(dirname "$mole_path")" && pwd)" install_dir="$(cd "$(dirname "$mole_path")" && pwd)"
# Run installer # Run installer quietly
if "$tmp_installer" --prefix "$install_dir" --config "$HOME/.config/mole" --update 2>/dev/null; then if "$tmp_installer" --prefix "$install_dir" --config "$HOME/.config/mole" --update 2>/dev/null; then
log_success "Mole updated successfully" log_success "Updated successfully"
else else
log_warning "Update failed, trying reinstall..." if "$tmp_installer" --prefix "$install_dir" --config "$HOME/.config/mole" 2>/dev/null; then
if "$tmp_installer" --prefix "$install_dir" --config "$HOME/.config/mole"; then log_success "Updated successfully"
log_success "Mole reinstalled successfully"
else else
rm -f "$tmp_installer" rm -f "$tmp_installer"
log_error "Update failed" log_error "Update failed"