Fix: winapp init crashing in non-interactive shells (use defaults behavior if non interactive)#559
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes winapp init behavior in non-interactive shells by detecting non-interactive console capabilities and automatically switching to default-value behavior to avoid Spectre.Console prompt exceptions.
Changes:
- Adds a non-interactive guard in
InitCommandthat logs a warning and enablesuseDefaults. - Updates the shared CLI test base so existing prompt-driven tests continue to run as interactive.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/winapp-CLI/WinApp.Cli/Commands/InitCommand.cs |
Adds non-interactive detection and fallback to default initialization behavior. |
src/winapp-CLI/WinApp.Cli.Tests/BaseCommandTests.cs |
Marks the shared TestConsole as interactive to preserve existing prompt test behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!useDefaults && !ansiConsole.Profile.Capabilities.Interactive) | ||
| { | ||
| logger.LogWarning("{Warning} Non-interactive environment detected. Using default values.", UiSymbols.Warning); | ||
| useDefaults = true; |
Build Metrics ReportBinary Sizes
Test Results✅ 1192 passed, 1 skipped out of 1193 tests in 520.7s (+2 tests, +57.8s vs. baseline) Test Coverage❌ 17.2% line coverage, 36.3% branch coverage · ✅ no change vs. baseline CLI Startup Time34ms median (x64, Updated 2026-06-01 18:28:42 UTC · commit |
fixes #556
Add check for non-interactive shells that uses
--use-defaultsbehavior and displays a warning.