-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·124 lines (97 loc) · 4.01 KB
/
install.sh
File metadata and controls
executable file
·124 lines (97 loc) · 4.01 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
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
set -euo pipefail
# ─────────────────────────────────────────────
# MailChimp CLI Installer
# ─────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BINARY_NAME="mailchimp"
INSTALL_DIR="$HOME/.local/bin"
SKILL_DIR="$SCRIPT_DIR/skills/mailchimp"
info() { echo -e "${CYAN}ℹ${NC} $*"; }
ok() { echo -e "${GREEN}✓${NC} $*"; }
warn() { echo -e "${YELLOW}⚠${NC} $*"; }
err() { echo -e "${RED}✗${NC} $*" >&2; }
echo ""
echo -e "${BOLD} MailChimp CLI Installer${NC}"
echo " ─────────────────────────"
echo ""
# ── Pre-flight checks ──────────────────────
if ! command -v cargo &>/dev/null; then
err "cargo not found. Install Rust: https://rustup.rs"
exit 1
fi
if [[ ! -f "$SCRIPT_DIR/Cargo.toml" ]]; then
err "Cargo.toml not found in $SCRIPT_DIR — run this from the repo root."
exit 1
fi
if [[ ! -f "$SKILL_DIR/SKILL.md" ]]; then
err "SKILL.md not found at $SKILL_DIR/SKILL.md"
exit 1
fi
# ── Build ───────────────────────────────────
info "Building release binary..."
(cd "$SCRIPT_DIR" && cargo build --release --quiet)
ok "Build complete"
# ── Install binary ──────────────────────────
mkdir -p "$INSTALL_DIR"
cp "$SCRIPT_DIR/target/release/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
ok "Installed ${BOLD}$BINARY_NAME${NC} → $INSTALL_DIR/$BINARY_NAME"
# ── Check PATH ──────────────────────────────
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
warn "$INSTALL_DIR is not in your PATH"
echo " Add this to your shell profile (~/.zshrc, ~/.bashrc, etc.):"
echo ""
echo -e " ${CYAN}export PATH=\"\$HOME/.local/bin:\$PATH\"${NC}"
echo ""
fi
# ── Install skill ───────────────────────────
install_skill() {
local agent_name="$1"
local target_dir="$2"
mkdir -p "$target_dir"
# Symlink the entire skill directory contents so docs/ comes along
ln -sf "$SKILL_DIR/SKILL.md" "$target_dir/SKILL.md"
# Symlink docs directory if it exists
if [[ -d "$SKILL_DIR/docs" ]]; then
ln -sfn "$SKILL_DIR/docs" "$target_dir/docs"
fi
ok "Installed skill → $target_dir ($agent_name)"
}
SKILL_INSTALLED=false
if [[ -d "$HOME/.claude" ]]; then
install_skill "Claude Code" "$HOME/.claude/skills/mailchimp"
SKILL_INSTALLED=true
fi
if [[ -d "$HOME/.codex" ]]; then
install_skill "Codex" "$HOME/.codex/skills/mailchimp"
SKILL_INSTALLED=true
fi
if [[ "$SKILL_INSTALLED" == false ]]; then
warn "Neither ~/.claude nor ~/.codex found — skill not installed."
echo " You can manually symlink later:"
echo ""
echo -e " ${CYAN}mkdir -p ~/.claude/skills/mailchimp${NC}"
echo -e " ${CYAN}ln -sf $SKILL_DIR/SKILL.md ~/.claude/skills/mailchimp/SKILL.md${NC}"
echo -e " ${CYAN}ln -sfn $SKILL_DIR/docs ~/.claude/skills/mailchimp/docs${NC}"
echo ""
fi
# ── Done ────────────────────────────────────
echo ""
echo -e "${GREEN}${BOLD} Installation complete!${NC}"
echo ""
echo " Get started:"
echo -e " ${CYAN}mailchimp auth login${NC} # authenticate"
echo -e " ${CYAN}mailchimp audiences list${NC} # list audiences"
echo -e " ${CYAN}mailchimp --help${NC} # see all commands"
echo ""
echo " Shell completions:"
echo -e " ${CYAN}eval \"\$(mailchimp completions zsh)\"${NC}"
echo ""