From ccb67cc99508b5f5b6db4e7c57e3058e68b7e716 Mon Sep 17 00:00:00 2001 From: sususu98 Date: Fri, 5 Dec 2025 16:26:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20Windows=20?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E5=BC=8F=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 setup.ps1,使用 Get-Command 检测 claude、gemini、codex 是否已安装, 显示安装状态后启动对应的配置脚本。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- setup.ps1 | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 setup.ps1 diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 0000000..1e89b95 --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,92 @@ +# XCodeCLI Setup Launcher (Windows) +# Interactive script to configure Claude Code, Gemini CLI, or Codex + +param( + [string]$ApiKey, + [switch]$Help +) + +if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key } + +function Write-Info { param([string]$Message); Write-Host "[INFO]" -ForegroundColor Blue -NoNewline; Write-Host " $Message" } +function Write-Success { param([string]$Message); Write-Host "[SUCCESS]" -ForegroundColor Green -NoNewline; Write-Host " $Message" } +function Write-Warning { param([string]$Message); Write-Host "[WARNING]" -ForegroundColor Yellow -NoNewline; Write-Host " $Message" } +function Write-Error { param([string]$Message); Write-Host "[ERROR]" -ForegroundColor Red -NoNewline; Write-Host " $Message" } + +function Show-Help { + Write-Host @" +XCodeCLI Setup Launcher (Windows) + +Usage: powershell -ExecutionPolicy Bypass -File setup.ps1 [OPTIONS] + +Options: + -ApiKey Pre-set the API key + -Help Show this help message +"@ + exit 0 +} + +function Test-Command { param([string]$Name); return [bool](Get-Command $Name -ErrorAction SilentlyContinue) } + +function Show-Menu { + $claudeStatus = if (Test-Command "claude") { "[已安装]" } else { "[未安装]" } + $geminiStatus = if (Test-Command "gemini") { "[已安装]" } else { "[未安装]" } + $codexStatus = if (Test-Command "codex") { "[已安装]" } else { "[未安装]" } + + Write-Host "" + Write-Host "========================================" -ForegroundColor Cyan + Write-Host " XCodeCLI Setup Launcher" -ForegroundColor Cyan + Write-Host "========================================" -ForegroundColor Cyan + Write-Host "" + Write-Host "Select the tool to configure:" -ForegroundColor Yellow + Write-Host "" + + $claudeColor = if (Test-Command "claude") { "Green" } else { "Red" } + $geminiColor = if (Test-Command "gemini") { "Green" } else { "Red" } + $codexColor = if (Test-Command "codex") { "Green" } else { "Red" } + + Write-Host " [1] Claude Code " -NoNewline; Write-Host $claudeStatus -ForegroundColor $claudeColor + Write-Host " [2] Gemini CLI " -NoNewline; Write-Host $geminiStatus -ForegroundColor $geminiColor + Write-Host " [3] Codex " -NoNewline; Write-Host $codexStatus -ForegroundColor $codexColor + Write-Host "" + Write-Host " [0] Exit" -ForegroundColor Gray + Write-Host "" +} + +function Get-ScriptPath { + param([int]$Choice) + $scriptDir = if ($PSScriptRoot) { $PSScriptRoot } else { "." } + + switch ($Choice) { + 1 { @("$scriptDir\ClaudeCode\setup-claude-code.ps1", "$scriptDir\setup-claude-code.ps1") | Where-Object { Test-Path $_ } | Select-Object -First 1 } + 2 { "$scriptDir\GeminiCLI\setup-gemini.ps1" } + 3 { "$scriptDir\codex\setup-codex.ps1" } + } +} + +function Main { + if ($Help) { Show-Help } + + Show-Menu + $choice = Read-Host "Enter your choice (0-3)" + + if ($choice -eq "0") { Write-Info "Goodbye!"; exit 0 } + + $choiceNum = [int]$choice + if ($choiceNum -lt 1 -or $choiceNum -gt 3) { Write-Error "Invalid choice."; exit 1 } + + $scriptPath = Get-ScriptPath -Choice $choiceNum + if (-not $scriptPath -or -not (Test-Path $scriptPath)) { + $toolNames = @{ 1 = "Claude Code"; 2 = "Gemini CLI"; 3 = "Codex" } + Write-Error "Setup script for $($toolNames[$choiceNum]) not found." + exit 1 + } + + Write-Host "" + Write-Info "Launching: $scriptPath" + Write-Host "" + + if ($ApiKey) { & $scriptPath -ApiKey $ApiKey } else { & $scriptPath } +} + +Main