-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun
More file actions
executable file
·37 lines (32 loc) · 1.1 KB
/
run
File metadata and controls
executable file
·37 lines (32 loc) · 1.1 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
#!/bin/zsh
set -euo pipefail
root_dir="$(cd "$(dirname "$0")" && pwd)"
if [[ ! -d "$root_dir/src-tauri" ]]; then
target_dir="${MAC_STATS_DIR:-$PWD/mac-stats}"
if [[ ! -d "$target_dir/src-tauri" ]]; then
if ! command -v git >/dev/null 2>&1; then
echo "Error: git is required to clone the repo." >&2
exit 1
fi
echo "Cloning repo to $target_dir ..."
git clone --depth 1 https://github.com/raro42/mac-stats.git "$target_dir"
fi
root_dir="$target_dir"
fi
cd "$root_dir/src-tauri"
# Check for help flag first
if [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
# Build first to ensure binary exists, then show help
cargo build --release 2>/dev/null || true
exec ./target/release/mac_stats --help
fi
# Check if first argument is "dev" for development mode
if [[ "${1:-release}" == "dev" ]]; then
shift # Remove "dev" from arguments
# Pass remaining arguments to cargo run (--bin mac_stats needed when multiple binaries exist)
cargo run --bin mac_stats -- "$@"
else
cargo build --release
# Pass all arguments to the binary
exec ./target/release/mac_stats "$@"
fi