|
| 1 | +# Webex CLI installer for Windows |
| 2 | +# Usage: irm https://raw.githubusercontent.com/Cloverhound/webex-cli/main/install.ps1 | iex |
| 3 | + |
| 4 | +$ErrorActionPreference = "Stop" |
| 5 | + |
| 6 | +$Repo = "Cloverhound/webex-cli" |
| 7 | +$Binary = "webex.exe" |
| 8 | +$InstallDir = "$env:LOCALAPPDATA\webex-cli" |
| 9 | + |
| 10 | +# Detect architecture |
| 11 | +$Arch = if ([Environment]::Is64BitOperatingSystem) { |
| 12 | + if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "amd64" } |
| 13 | +} else { |
| 14 | + Write-Error "Unsupported: 32-bit Windows is not supported" |
| 15 | + return |
| 16 | +} |
| 17 | + |
| 18 | +# Get latest version |
| 19 | +Write-Host "Fetching latest release..." |
| 20 | +$Release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest" |
| 21 | +$Version = $Release.tag_name -replace '^v', '' |
| 22 | +if (-not $Version) { |
| 23 | + Write-Error "Could not determine latest version" |
| 24 | + return |
| 25 | +} |
| 26 | +Write-Host "Latest version: v$Version" |
| 27 | + |
| 28 | +# Download |
| 29 | +$ZipName = "webex-cli_${Version}_windows_${Arch}.zip" |
| 30 | +$Url = "https://github.com/$Repo/releases/download/v$Version/$ZipName" |
| 31 | + |
| 32 | +$TmpDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "webex-cli-install-$(Get-Random)") |
| 33 | + |
| 34 | +try { |
| 35 | + Write-Host "Downloading $Url..." |
| 36 | + Invoke-WebRequest -Uri $Url -OutFile (Join-Path $TmpDir $ZipName) |
| 37 | + |
| 38 | + # Extract |
| 39 | + Expand-Archive -Path (Join-Path $TmpDir $ZipName) -DestinationPath $TmpDir -Force |
| 40 | + |
| 41 | + # Install |
| 42 | + New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null |
| 43 | + Move-Item -Path (Join-Path $TmpDir $Binary) -Destination (Join-Path $InstallDir $Binary) -Force |
| 44 | + |
| 45 | + # Add to user PATH if not already there |
| 46 | + $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") |
| 47 | + if ($UserPath -notlike "*$InstallDir*") { |
| 48 | + [Environment]::SetEnvironmentVariable("Path", "$InstallDir;$UserPath", "User") |
| 49 | + $env:Path = "$InstallDir;$env:Path" |
| 50 | + Write-Host "Added $InstallDir to your PATH." |
| 51 | + } |
| 52 | + |
| 53 | + Write-Host "" |
| 54 | + Write-Host "Installed webex v$Version to $InstallDir\$Binary" |
| 55 | + Write-Host "" |
| 56 | + Write-Host "NOTE: Restart your terminal for PATH changes to take effect." |
| 57 | + Write-Host "" |
| 58 | + Write-Host "Get started:" |
| 59 | + Write-Host " webex config set client-id <your-client-id> # if not using built-in defaults" |
| 60 | + Write-Host " webex config set client-secret <your-client-secret>" |
| 61 | + Write-Host " webex login" |
| 62 | +} finally { |
| 63 | + Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue |
| 64 | +} |
0 commit comments