From 54f3ea01e274a659fbdde84f1bc6a69a5d96b7b0 Mon Sep 17 00:00:00 2001 From: sususu98 Date: Fri, 12 Dec 2025 10:58:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20setup.sh=20=E6=B7=BB=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=80=89=E6=8B=A9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.sh | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/setup.sh b/setup.sh index 16ac1cf..98e600c 100755 --- a/setup.sh +++ b/setup.sh @@ -187,9 +187,12 @@ show_status() { color="${RED}" 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 echo "" + echo -e " [${CYAN}a${NC}] 配置全部工具" + echo -e " [${CYAN}0${NC}] 退出" + echo "" } # ========== 主函数 ========== @@ -215,8 +218,30 @@ main() { # 显示状态 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 if [[ -z "$api_key" ]]; then + echo "" echo -e "${YELLOW}请输入 API 密钥:${NC}" read -r api_key if [[ -z "$api_key" ]]; then @@ -243,19 +268,22 @@ main() { echo "" echo -e "${CYAN}========================================${NC}" - echo -e "${CYAN} 开始安装和配置所有工具${NC}" + echo -e "${CYAN} 开始安装和配置工具${NC}" echo -e "${CYAN}========================================${NC}" echo "" 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_cmd=$(get_tool_cmd "$i") echo "" - echo -e "${YELLOW}>>> [$i/3] $tool_name${NC}" + echo -e "${YELLOW}>>> [$current/$total] $tool_name${NC}" echo "" # 检测是否已安装 @@ -282,13 +310,10 @@ main() { echo "" if [[ $failed -eq 0 ]]; then - success "所有工具安装配置成功!" + success "所有选中的工具配置成功!" else warning "有 $failed 个工具配置失败" fi - - echo "" - show_status } main "$@"