Skip to content

Commit 338675c

Browse files
committed
unstall.sh
1 parent 95d5d9e commit 338675c

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

uninstall.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Colors
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
log_info() {
11+
printf "${GREEN}[INFO]${NC} %s\n" "$1"
12+
}
13+
14+
log_warn() {
15+
printf "${YELLOW}[WARN]${NC} %s\n" "$1"
16+
}
17+
18+
log_error() {
19+
printf "${RED}[ERROR]${NC} %s\n" "$1"
20+
}
21+
22+
# Detect config directory (matches Go's os.UserConfigDir)
23+
detect_config_dir() {
24+
case "$(uname -s)" in
25+
Darwin*) echo "$HOME/Library/Application Support";;
26+
Linux*) echo "$HOME/.config";;
27+
CYGWIN*|MINGW*) echo "$APPDATA";;
28+
*) echo "$HOME/.config";;
29+
esac
30+
}
31+
32+
# Prompt user for confirmation
33+
prompt() {
34+
if [ "$ASSUME_YES" = "1" ]; then
35+
return 0
36+
fi
37+
printf "%s [y/N]: " "$1"
38+
read -r answer
39+
case "$answer" in
40+
[yY][eE][sS]|[yY]) return 0 ;;
41+
*) return 1 ;;
42+
esac
43+
}
44+
45+
uninstall() {
46+
log_info "Uninstalling menlo..."
47+
48+
# Remove binary
49+
log_info "Removing binary from /usr/local/bin..."
50+
if [ -f /usr/local/bin/menlo ]; then
51+
if [ -w /usr/local/bin/menlo ]; then
52+
rm /usr/local/bin/menlo
53+
else
54+
log_warn "Need sudo to remove binary"
55+
sudo rm /usr/local/bin/menlo
56+
fi
57+
log_info "Binary removed"
58+
else
59+
log_info "Binary not found at /usr/local/bin/menlo"
60+
fi
61+
62+
# Detect config directory
63+
CONFIG_BASE_DIR=$(detect_config_dir)
64+
CONFIG_DIR="$CONFIG_BASE_DIR/menlo"
65+
66+
# Ask about config removal
67+
if [ -d "$CONFIG_DIR" ]; then
68+
if prompt "Remove config directory ($CONFIG_DIR)?"; then
69+
rm -rf "$CONFIG_DIR"
70+
log_info "Config directory removed"
71+
else
72+
log_info "Keeping config directory"
73+
fi
74+
else
75+
log_info "Config directory not found"
76+
fi
77+
78+
log_info "Uninstall complete!"
79+
80+
# Show instructions for shell completions
81+
case "$(uname -s)" in
82+
Darwin*)
83+
CONFIG_DIR="$HOME/Library/Application Support/menlo"
84+
;;
85+
Linux*)
86+
CONFIG_DIR="$HOME/.config/menlo"
87+
;;
88+
CYGWIN*|MINGW*)
89+
CONFIG_DIR="$APPDATA/menlo"
90+
;;
91+
esac
92+
93+
log_info "Shell completions are in: $CONFIG_DIR/completions/"
94+
log_info "Remove these lines from your shell rc file if you added them:"
95+
log_info " source $CONFIG_DIR/completions/zsh # for zsh"
96+
log_info " source $CONFIG_DIR/completions/fish # for fish"
97+
log_info " source $CONFIG_DIR/completions/bash # for bash"
98+
}
99+
100+
# Check if curl is installed
101+
if ! command -v curl >/dev/null 2>&1; then
102+
log_error "curl is required but not installed. Please install curl first."
103+
exit 1
104+
fi
105+
106+
# Parse arguments
107+
while [ $# -gt 0 ]; do
108+
case "$1" in
109+
-h|--help)
110+
echo "Usage: sh uninstall.sh"
111+
echo ""
112+
echo "Options:"
113+
echo " -h, --help Show this help message"
114+
exit 0
115+
;;
116+
-y|--yes)
117+
# Non-interactive mode - assume yes to all prompts
118+
export ASSUME_YES=1
119+
;;
120+
*)
121+
log_error "Unknown option: $1"
122+
echo "Use -h or --help for usage information"
123+
exit 1
124+
;;
125+
esac
126+
done
127+
128+
# Run uninstall
129+
uninstall

0 commit comments

Comments
 (0)