-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-mac.command
More file actions
69 lines (61 loc) · 2.69 KB
/
Copy pathrun-mac.command
File metadata and controls
69 lines (61 loc) · 2.69 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
#!/bin/bash
# This file is part of ZippyServe
# run-mac.command
# Author(s): Gabriel Mongefranco; Eisenberg Family Depression Center.
# Created: 2026-07-26
# Summary: macOS launch script for ZippyServe. Wraps the arch-matched
# bin/ZippyServe-mac-* binary, serving this script's own directory by
# default, and opens the default browser. Double-clickable in Finder.
# Notes: See README file for documentation and full license information.
#
# Copyright © 2026 The Regents of the University of Michigan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
### Pick the binary matching this Mac's CPU architecture ###
ARCH="$(uname -m)"
if [ "$ARCH" = "arm64" ]; then
EXE_PATH="$SCRIPT_DIR/bin/ZippyServe-mac-arm64"
else
EXE_PATH="$SCRIPT_DIR/bin/ZippyServe-mac-amd64"
fi
PORT=8010
DIR="$SCRIPT_DIR"
SERVER_ARGS=()
### Parse and forward server flags ###
while [ $# -gt 0 ]; do
case "$1" in
--port=*) PORT="${1#*=}" ;;
--port) PORT="$2"; shift ;;
--dir=*) DIR="${1#*=}" ;;
--dir) DIR="$2"; shift ;;
--zip=*) SERVER_ARGS+=("-zip" "${1#*=}") ;;
--zip) SERVER_ARGS+=("-zip" "$2"); shift ;;
--compressed=*) SERVER_ARGS+=("-compressed" "${1#*=}") ;;
--compressed) SERVER_ARGS+=("-compressed" "$2"); shift ;;
--tar=*) SERVER_ARGS+=("-tar" "${1#*=}") ;;
--tar) SERVER_ARGS+=("-tar" "$2"); shift ;;
--gz=*) SERVER_ARGS+=("-gz" "${1#*=}") ;;
--gz) SERVER_ARGS+=("-gz" "$2"); shift ;;
--index=*) SERVER_ARGS+=("-index" "${1#*=}") ;;
--index) SERVER_ARGS+=("-index" "$2"); shift ;;
*) echo "Unknown argument: $1" >&2; exit 1 ;;
esac
shift
done
if [ ! -f "$EXE_PATH" ]; then
echo "ZippyServe binary not found at '$EXE_PATH'. Run build.sh first, or copy bin/ZippyServe-mac-$ARCH alongside this script." >&2
exit 1
fi
chmod +x "$EXE_PATH"
open "http://localhost:$PORT"
exec "$EXE_PATH" -port "$PORT" -dir "$DIR" "${SERVER_ARGS[@]}"