11$ErrorActionPreference = ' Stop'
22
3+ # Non-interactive mode for unattended installs (CI, scripted setup). Skips all
4+ # prompts and Clear-Host calls. Same env var name as install.sh.
5+ $nonInteractive = ($env: CODEPLAIN_INSTALL_NONINTERACTIVE -eq " 1" )
6+ if ($nonInteractive ) {
7+ Write-Host " running in non-interactive mode (CODEPLAIN_INSTALL_NONINTERACTIVE=1)"
8+ }
9+
310# Base URL for additional scripts
411if (-not $env: CODEPLAIN_SCRIPTS_BASE_URL ) {
512 $env: CODEPLAIN_SCRIPTS_BASE_URL = " https://codeplain.ai"
@@ -34,7 +41,7 @@ $env:GRAY_LIGHT = $GRAY_LIGHT
3441$env: BOLD = $BOLD
3542$env: NC = $NC
3643
37- Clear-Host
44+ if ( -not $nonInteractive ) { Clear-Host }
3845Write-Host " started ${YELLOW}${BOLD} *codeplain CLI${NC} installation..."
3946
4047# Install uv if not present
@@ -94,7 +101,7 @@ if ($codeplainLine) {
94101 Write-Host " installing codeplain...${NC} "
95102 Write-Host " "
96103 uv tool install codeplain
97- Clear-Host
104+ if ( -not $nonInteractive ) { Clear-Host }
98105 Write-Host " ${GREEN} ✓ codeplain installed successfully!${NC} "
99106}
100107
@@ -119,25 +126,34 @@ Write-Host ""
119126# Check if API key already exists
120127$skipApiKeySetup = $false
121128if ($env: CODEPLAIN_API_KEY ) {
122- Write-Host " you already have an API key configured."
123- Write-Host " "
124- Write-Host " would you like to log in and get a new one?"
125- Write-Host " "
126- $getNewKey = Read-Host " [y/N]"
127- Write-Host " "
128-
129- if ($getNewKey -notmatch ' ^[Yy]$' ) {
130- Write-Host " ${GREEN} ✓${NC} using existing API key."
129+ if ($nonInteractive ) {
130+ Write-Host " ${GREEN} ✓${NC} using existing CODEPLAIN_API_KEY (non-interactive mode)."
131131 $skipApiKeySetup = $true
132+ } else {
133+ Write-Host " you already have an API key configured."
134+ Write-Host " "
135+ Write-Host " would you like to log in and get a new one?"
136+ Write-Host " "
137+ $getNewKey = Read-Host " [y/N]"
138+ Write-Host " "
139+
140+ if ($getNewKey -notmatch ' ^[Yy]$' ) {
141+ Write-Host " ${GREEN} ✓${NC} using existing API key."
142+ $skipApiKeySetup = $true
143+ }
132144 }
133145}
134146
135147$apiKey = $null
136148if (-not $skipApiKeySetup ) {
137- Write-Host " go to ${YELLOW} https://platform.codeplain.ai${NC} and sign up to get your API key."
138- Write-Host " "
139- $apiKey = Read-Host " paste your API key here"
140- Write-Host " "
149+ if ($nonInteractive ) {
150+ Write-Host " ${GRAY} no CODEPLAIN_API_KEY set; skipping key setup (non-interactive mode).${NC} "
151+ } else {
152+ Write-Host " go to ${YELLOW} https://platform.codeplain.ai${NC} and sign up to get your API key."
153+ Write-Host " "
154+ $apiKey = Read-Host " paste your API key here"
155+ Write-Host " "
156+ }
141157}
142158
143159if ($skipApiKeySetup ) {
@@ -155,7 +171,7 @@ if ($skipApiKeySetup) {
155171}
156172
157173# ASCII Art Welcome
158- Clear-Host
174+ if ( -not $nonInteractive ) { Clear-Host }
159175Write-Host " "
160176Write-Host " ${NC} "
161177Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
@@ -178,10 +194,14 @@ Write-Host ""
178194Write-Host " "
179195Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
180196Write-Host " "
181- Write-Host " would you like to get a quick intro to ***plain specification language?"
182- Write-Host " "
183- $walkthroughChoice = Read-Host " [Y/n]"
184- Write-Host " "
197+ if ($nonInteractive ) {
198+ $walkthroughChoice = " n"
199+ } else {
200+ Write-Host " would you like to get a quick intro to ***plain specification language?"
201+ Write-Host " "
202+ $walkthroughChoice = Read-Host " [Y/n]"
203+ Write-Host " "
204+ }
185205
186206# Determine script directory for local execution
187207$ScriptDir = " "
@@ -225,27 +245,31 @@ if ($walkthroughChoice -notmatch '^[Nn]$') {
225245}
226246
227247# Download examples step
228- Clear-Host
229- Write-Host " "
230- Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
231- Write-Host " ${YELLOW}${BOLD} Example Projects${NC} "
232- Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
233- Write-Host " "
234- Write-Host " we've prepared some example Plain projects for you"
235- Write-Host " to explore and experiment with."
236- Write-Host " "
237- Write-Host " would you like to download them?"
238- Write-Host " "
239- $downloadExamples = Read-Host " [Y/n]"
240- Write-Host " "
248+ if ($nonInteractive ) {
249+ $downloadExamples = " n"
250+ } else {
251+ Clear-Host
252+ Write-Host " "
253+ Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
254+ Write-Host " ${YELLOW}${BOLD} Example Projects${NC} "
255+ Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
256+ Write-Host " "
257+ Write-Host " we've prepared some example Plain projects for you"
258+ Write-Host " to explore and experiment with."
259+ Write-Host " "
260+ Write-Host " would you like to download them?"
261+ Write-Host " "
262+ $downloadExamples = Read-Host " [Y/n]"
263+ Write-Host " "
264+ }
241265
242266# Run examples download if user agrees
243267if ($downloadExamples -notmatch ' ^[Nn]$' ) {
244268 Invoke-SubScript " examples.ps1"
245269}
246270
247271# Final message
248- Clear-Host
272+ if ( -not $nonInteractive ) { Clear-Host }
249273Write-Host " "
250274Write-Host " ${GRAY} ────────────────────────────────────────────${NC} "
251275Write-Host " ${YELLOW}${BOLD} You're all set!${NC} "
0 commit comments