-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·111 lines (94 loc) · 2.94 KB
/
install.sh
File metadata and controls
executable file
·111 lines (94 loc) · 2.94 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
107
108
109
110
111
#!/bin/bash
# install.sh - install the typg CLI on the current machine
# made by FontLab https://www.fontlab.com/
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
usage() {
cat << EOF
Usage: $0 [OPTIONS]
Install the typg CLI binary on the current machine.
OPTIONS:
--debug Install debug build (faster compile, slower runtime)
--hpindex Enable high-performance LMDB index feature
--path DIR Install to DIR instead of ~/.cargo/bin
-h, --help Show this help
Examples:
$0 # Release install to ~/.cargo/bin
$0 --hpindex # With LMDB index support
$0 --path /usr/local/bin # Install to custom location
$0 --debug # Debug build (faster compile)
EOF
}
INSTALL_DIR=""
BUILD_FLAGS="--release"
FEATURE_FLAGS=""
while [[ $# -gt 0 ]]; do
case "$1" in
--debug)
BUILD_FLAGS=""
shift
;;
--hpindex)
FEATURE_FLAGS="--features hpindex"
shift
;;
--path)
INSTALL_DIR="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
log_error "Unknown option: $1"
usage
exit 1
;;
esac
done
# Check for cargo
if ! command -v cargo >/dev/null 2>&1; then
log_error "cargo not found. Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
exit 1
fi
if [[ -n "$INSTALL_DIR" ]]; then
# Build and copy manually
log_info "Building typg CLI..."
cargo build -p typg-cli $BUILD_FLAGS $FEATURE_FLAGS --manifest-path "$SCRIPT_DIR/Cargo.toml"
local_target="$SCRIPT_DIR/target"
if [[ -n "$BUILD_FLAGS" ]]; then
bin_path="$local_target/release/typg"
else
bin_path="$local_target/debug/typg"
fi
if [[ ! -f "$bin_path" ]]; then
log_error "Build succeeded but binary not found at $bin_path"
exit 1
fi
mkdir -p "$INSTALL_DIR"
cp "$bin_path" "$INSTALL_DIR/typg"
chmod +x "$INSTALL_DIR/typg"
log_success "Installed typg to $INSTALL_DIR/typg"
else
# Use cargo install (installs to ~/.cargo/bin by default)
log_info "Installing typg CLI via cargo install..."
cargo install --path "$SCRIPT_DIR/cli" $FEATURE_FLAGS
log_success "Installed typg to $(which typg 2>/dev/null || echo '~/.cargo/bin/typg')"
fi
# Verify
if command -v typg >/dev/null 2>&1; then
log_success "typg is ready: $(typg --version 2>/dev/null || echo 'installed')"
else
log_warning "typg was installed but is not on PATH. Add the install directory to your PATH."
fi