Skip to content

Commit 8ce6163

Browse files
committed
Add install.sh and document release install
Add a simple install/uninstall script (install.sh) to copy the perspective binary and mlx.metallib into a target directory (default /usr/local/bin). Update build.sh to include install.sh in the distribution stage and to print instructions that use the installer (tar + ./install.sh). Update README.md with new "Install from Release" instructions, examples for custom install path and uninstall, and adjusted build/release instructions (including swift run and ./build.sh dist). These changes make creating and installing releases easier and document the recommended install flow.
1 parent 11e2ab9 commit 8ce6163

3 files changed

Lines changed: 87 additions & 7 deletions

File tree

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,41 @@ A lightweight, open-source Swift CLI for running **Apple Foundation Models** and
1111

1212
Foundation Models requires Apple Intelligence to be enabled. MLX mode works on any Apple Silicon Mac.
1313

14-
## Quick Start
14+
## Install from Release
15+
16+
Download the latest release archive, then:
17+
18+
```bash
19+
tar xzf perspective-cli-*.tar.gz
20+
cd perspective-cli-*
21+
./install.sh
22+
```
23+
24+
This installs `perspective` and `mlx.metallib` to `/usr/local/bin/`. To install elsewhere:
25+
26+
```bash
27+
./install.sh /opt/bin
28+
```
29+
30+
To uninstall:
31+
32+
```bash
33+
./install.sh --uninstall
34+
```
35+
36+
## Build from Source
1537

1638
```bash
1739
git clone https://github.com/your-username/PerspectiveCLI.git
1840
cd PerspectiveCLI
1941
./build.sh
42+
swift run PerspectiveCLI
2043
```
2144

22-
Or build manually:
45+
To create a release archive:
2346

2447
```bash
25-
swift build
26-
swift run PerspectiveCLI
48+
./build.sh dist
2749
```
2850

2951
## Usage

build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ if $DIST; then
110110

111111
cp "$BIN_DIR/PerspectiveCLI" "$STAGE/perspective"
112112
cp "$METALLIB" "$STAGE/mlx.metallib"
113+
cp "$PROJECT_DIR/install.sh" "$STAGE/"
113114
cp "$PROJECT_DIR/LICENSE" "$STAGE/" 2>/dev/null || true
114115
cp "$PROJECT_DIR/README.md" "$STAGE/"
115116

@@ -122,10 +123,10 @@ if $DIST; then
122123
echo " $ARCHIVE"
123124
echo " SHA-256: $SHA"
124125
echo ""
125-
echo "To install manually:"
126+
echo "To install:"
126127
echo " tar xzf $(basename "$ARCHIVE")"
127-
echo " cp perspective-cli-${VERSION}/perspective /usr/local/bin/"
128-
echo " cp perspective-cli-${VERSION}/mlx.metallib /usr/local/bin/"
128+
echo " cd perspective-cli-${VERSION}"
129+
echo " ./install.sh"
129130
fi
130131

131132
echo "Build complete."

install.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# install.sh — Install PerspectiveCLI
3+
#
4+
# Usage:
5+
# ./install.sh Install to /usr/local/bin (default)
6+
# ./install.sh /custom/path Install to a custom directory
7+
# ./install.sh --uninstall Remove installed files
8+
9+
set -euo pipefail
10+
11+
INSTALL_DIR="${1:-/usr/local/bin}"
12+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
13+
14+
# ── Uninstall ─────────────────────────────────────────────────────────
15+
if [ "${1:-}" = "--uninstall" ]; then
16+
INSTALL_DIR="/usr/local/bin"
17+
echo "Uninstalling Perspective CLI from $INSTALL_DIR..."
18+
rm -f "$INSTALL_DIR/perspective"
19+
rm -f "$INSTALL_DIR/mlx.metallib"
20+
echo "Done."
21+
exit 0
22+
fi
23+
24+
# ── Install ───────────────────────────────────────────────────────────
25+
echo "Installing Perspective CLI to $INSTALL_DIR..."
26+
27+
# Check that the binary exists in the same directory as this script
28+
if [ ! -f "$SCRIPT_DIR/perspective" ]; then
29+
echo "Error: 'perspective' binary not found in $SCRIPT_DIR"
30+
echo "Run this script from inside the extracted archive."
31+
exit 1
32+
fi
33+
34+
# Create install directory if needed
35+
mkdir -p "$INSTALL_DIR"
36+
37+
# Copy files
38+
cp "$SCRIPT_DIR/perspective" "$INSTALL_DIR/perspective"
39+
chmod +x "$INSTALL_DIR/perspective"
40+
41+
if [ -f "$SCRIPT_DIR/mlx.metallib" ]; then
42+
cp "$SCRIPT_DIR/mlx.metallib" "$INSTALL_DIR/mlx.metallib"
43+
fi
44+
45+
echo "Done."
46+
echo ""
47+
echo " perspective → $INSTALL_DIR/perspective"
48+
if [ -f "$SCRIPT_DIR/mlx.metallib" ]; then
49+
echo " mlx.metallib → $INSTALL_DIR/mlx.metallib"
50+
fi
51+
echo ""
52+
53+
# Check if install dir is on PATH
54+
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
55+
echo "Note: $INSTALL_DIR is not on your PATH."
56+
echo "Add it with: export PATH=\"$INSTALL_DIR:\$PATH\""
57+
fi

0 commit comments

Comments
 (0)