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