-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.command
More file actions
executable file
·106 lines (95 loc) · 2.79 KB
/
setup.command
File metadata and controls
executable file
·106 lines (95 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
set -eu
cd "$(dirname "$0")"
CODEX_MATE_BIN="./CodexMate"
if [ -n "${TERM:-}" ] && [ "${TERM:-}" != "dumb" ]; then
clear || true
fi
printf '%s\n' '========================================'
printf '%s\n' ' Codex Mate Setup'
printf '%s\n' '========================================'
printf '\n'
printf '%s\n' '[1] Install Codex Mate'
printf '%s\n' '[2] Uninstall Codex Mate'
printf '%s\n' '[3] Update Codex Mate'
printf '%s\n' '[4] Export diagnostic logs'
printf '%s\n' '[5] Exit'
printf '\n'
printf '%s' 'Please select an option [1-5]: '
read choice
find_python() {
if command -v python3 >/dev/null 2>&1; then
command -v python3
return
fi
if command -v python >/dev/null 2>&1; then
command -v python
return
fi
return 1
}
PYTHON_BIN="$(find_python || true)"
run_codex_mate() {
if [ -x "$CODEX_MATE_BIN" ]; then
"$CODEX_MATE_BIN" "$@"
return
fi
if [ -n "${PYTHON_BIN}" ]; then
"$PYTHON_BIN" -m codex_mate "$@"
return
fi
printf '\n%s\n' 'Python was not found and the bundled CodexMate executable is not in this folder.'
printf '%s\n' 'Download CodexMate-macos.zip from the latest GitHub Release, unzip it, then run setup.command again.'
printf '\n%s' 'Press Enter to close...'
read _
exit 1
}
run_install() {
if [ ! -x "$CODEX_MATE_BIN" ]; then
if [ -z "${PYTHON_BIN}" ]; then
run_codex_mate setup
fi
printf '\n%s\n' 'Installing Python package...'
"$PYTHON_BIN" -m pip install -e .
else
printf '\n%s\n' 'Using bundled CodexMate executable.'
fi
printf '\n%s\n' 'Installing Codex Mate LaunchAgent and transparent watcher...'
run_codex_mate setup
printf '\n%s\n' 'Codex Mate installed successfully.'
printf '%s\n' 'You can keep launching Codex from your normal entry point; Codex Mate will take over automatically.'
}
run_uninstall() {
printf '\n%s\n' 'Uninstalling Codex Mate LaunchAgent, transparent watcher, and legacy app shortcut...'
run_codex_mate remove
printf '\n%s\n' 'Codex Mate uninstalled successfully.'
}
run_update() {
printf '\n%s\n' 'Updating Codex Mate from GitHub Release...'
if [ -x "$CODEX_MATE_BIN" ]; then
printf '%s\n' 'Bundled executable installs are updated by downloading the latest CodexMate-macos.zip and running setup.command again.'
else
run_codex_mate update
printf '\n%s\n' 'Codex Mate update finished.'
fi
}
run_logs() {
printf '\n%s\n' 'Exporting diagnostic logs...'
run_codex_mate logs
printf '\n%s\n' 'Please send the generated CodexMate-diagnostics zip file to the maintainer.'
}
case "$choice" in
1) run_install ;;
2) run_uninstall ;;
3) run_update ;;
4) run_logs ;;
5) exit 0 ;;
*)
printf '\n%s\n' 'Invalid choice.'
printf '\n%s' 'Press Enter to close...'
read _
exit 1
;;
esac
printf '\n%s' 'Press Enter to close...'
read _