Private
Public Access
1
0

feat: setup.sh 添加工具选择菜单

This commit is contained in:
2025-12-12 10:58:30 +08:00
parent 23bc543fd1
commit 54f3ea01e2

View File

@@ -187,9 +187,12 @@ show_status() {
color="${RED}" color="${RED}"
fi fi
printf " %-12s %b%s%b\n" "$tool_name" "$color" "$status" "$NC" printf " [%d] %-12s %b%s%b\n" "$i" "$tool_name" "$color" "$status" "$NC"
done done
echo "" echo ""
echo -e " [${CYAN}a${NC}] 配置全部工具"
echo -e " [${CYAN}0${NC}] 退出"
echo ""
} }
# ========== 主函数 ========== # ========== 主函数 ==========
@@ -215,8 +218,30 @@ main() {
# 显示状态 # 显示状态
show_status show_status
# 选择要配置的工具
echo -e "${YELLOW}请选择要配置的工具 (1/2/3/a/0):${NC}"
read -r choice
# 退出
if [[ "$choice" == "0" ]]; then
info "再见!"
exit 0
fi
# 验证选择
local tools_to_configure=""
if [[ "$choice" == "a" || "$choice" == "A" ]]; then
tools_to_configure="1 2 3"
elif [[ "$choice" =~ ^[1-3]$ ]]; then
tools_to_configure="$choice"
else
error "无效的选择"
exit 1
fi
# 检查 API Key # 检查 API Key
if [[ -z "$api_key" ]]; then if [[ -z "$api_key" ]]; then
echo ""
echo -e "${YELLOW}请输入 API 密钥:${NC}" echo -e "${YELLOW}请输入 API 密钥:${NC}"
read -r api_key read -r api_key
if [[ -z "$api_key" ]]; then if [[ -z "$api_key" ]]; then
@@ -243,19 +268,22 @@ main() {
echo "" echo ""
echo -e "${CYAN}========================================${NC}" echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN} 开始安装和配置所有工具${NC}" echo -e "${CYAN} 开始安装和配置工具${NC}"
echo -e "${CYAN}========================================${NC}" echo -e "${CYAN}========================================${NC}"
echo "" echo ""
local failed=0 local failed=0
local total=$(echo $tools_to_configure | wc -w | tr -d ' ')
local current=0
# 安装和配置每个工具 # 安装和配置选中的工具
for i in 1 2 3; do for i in $tools_to_configure; do
current=$((current + 1))
local tool_name=$(get_tool_name "$i") local tool_name=$(get_tool_name "$i")
local tool_cmd=$(get_tool_cmd "$i") local tool_cmd=$(get_tool_cmd "$i")
echo "" echo ""
echo -e "${YELLOW}>>> [$i/3] $tool_name${NC}" echo -e "${YELLOW}>>> [$current/$total] $tool_name${NC}"
echo "" echo ""
# 检测是否已安装 # 检测是否已安装
@@ -282,13 +310,10 @@ main() {
echo "" echo ""
if [[ $failed -eq 0 ]]; then if [[ $failed -eq 0 ]]; then
success "所有工具安装配置成功!" success "所有选中的工具配置成功!"
else else
warning "$failed 个工具配置失败" warning "$failed 个工具配置失败"
fi fi
echo ""
show_status
} }
main "$@" main "$@"