feat: setup.sh 添加工具选择菜单
This commit is contained in:
43
setup.sh
43
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 "$@"
|
||||
|
||||
Reference in New Issue
Block a user