gitlink-cli/scripts/setup-local-cli.sh

60 lines
2.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# ================================================================
# gitlink-cli 本地编译安装脚本
# 功能:编译本地源码并替换 PATH 中的旧版本
# 使用bash scripts/setup-local-cli.sh
# ================================================================
set -e
echo "============================================"
echo " gitlink-cli 本地编译安装"
echo "============================================"
cd "$(dirname "$0")/.."
# 1. 检查 Go 环境
if ! command -v go &> /dev/null; then
echo "[ERROR] 未找到 Go请先安装 Go 1.21+"
exit 1
fi
echo "[INFO] Go 版本: $(go version)"
# 2. 编译
echo "[INFO] 编译 gitlink-cli..."
go build -o gitlink-cli.exe . 2>&1
echo "[INFO] 编译完成: $(ls -lh gitlink-cli.exe | awk '{print $5}')"
# 3. 验证编译版本
echo "[INFO] 验证命令完整性..."
if ./gitlink-cli.exe commit --help > /dev/null 2>&1; then
echo "[INFO] ✅ commit +list 可用"
else
echo "[WARN] commit 命令不可用,请检查代码"
fi
if ./gitlink-cli.exe collaborator --help > /dev/null 2>&1; then
echo "[INFO] ✅ collaborator +list 可用"
else
echo "[WARN] collaborator 命令不可用"
fi
# 4. 提供 PATH 设置说明
echo ""
echo "============================================"
echo " 安装完成"
echo "============================================"
echo ""
echo "本地编译版本: $(pwd)/gitlink-cli.exe"
echo ""
echo "方式一:设置别名(推荐,仅当前终端有效)"
echo " alias gitlink-cli='$(pwd)/gitlink-cli.exe'"
echo ""
echo "方式二:添加到 PATH永久有效需管理员权限"
echo " export PATH=\"$(pwd):\$PATH\""
echo " 或将上面这行添加到 ~/.bashrc 或 ~/.bash_profile"
echo ""
echo "方式三:直接使用 detect-cli.sh已在子任务三/四脚本中集成)"
echo " source skills/gitlink-shared/scripts/detect-cli.sh"
echo ""
echo "验证:"
echo " gitlink-cli commit +list --owner z2_cc --repo gitlink-cli --limit 3 --format json"