Skip to content

Conversation

@NotMyself
Copy link

Summary

Adds a --no-interactive CLI flag that disables the interactive REPL console for commands that extend InteractiveCommand (like preview). This enables running these commands in headless environments.

Fixes #283

Changes

  • Added --no-interactive flag to PipelinesCommandSettings
  • Modified InteractiveCommand.ExecuteEngineAsync() to skip REPL when flag is set
  • Added IsConsoleAvailable() helper for auto-detection of console availability
  • Non-interactive mode still supports file watching and rebuilds

Use Cases

This enables running preview (and similar commands) in:

  • CI/CD pipelines
  • Docker containers without TTY
  • Background processes
  • IDE task runners (VS Code tasks, Claude Code, etc.)
  • Any environment where stdout is redirected to a log file

Usage

# Explicit non-interactive mode
dotnet run -- preview --no-interactive

# With log file redirection (now works!)
dotnet run -- preview --no-interactive > preview.log 2>&1

# Combined with existing --log-file flag
dotnet run -- preview --no-interactive --log-file preview.log

Behavior

Mode REPL File Watching Ctrl+C Auto-rebuild
Interactive (default)
--no-interactive

Backward Compatibility

  • Default behavior is unchanged (interactive mode when console available)
  • Auto-detection fallback: if console isn't available, automatically uses non-interactive mode
  • File watching and live reload work identically in both modes

Test Plan

  • Verify preview works normally without the flag (interactive mode)
  • Verify preview --no-interactive runs without REPL prompt
  • Verify file watching still triggers rebuilds in non-interactive mode
  • Verify Ctrl+C exits cleanly in non-interactive mode
  • Verify output can be redirected to file with --no-interactive
  • Verify auto-detection works when spawned without console

🤖 Generated with Claude Code

Adds a --no-interactive CLI flag to PipelinesCommandSettings that
disables the interactive REPL console. This enables running commands
like `preview` in headless environments such as:

- CI/CD pipelines
- Docker containers without TTY
- Background processes
- IDE task runners (VS Code, Claude Code, etc.)

When --no-interactive is set (or console is unavailable), the command
will still watch for file changes and rebuild, but won't attempt to
use console operations that require valid handles (cursor positioning,
ReadKey, etc.).

Also adds auto-detection via IsConsoleAvailable() that checks if
console operations would succeed, falling back to non-interactive
mode automatically when no console is present.

Fixes statiqdev#283

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Jan 16, 2026

CLA assistant check
All committers have signed the CLA.

@NotMyself
Copy link
Author

Hi @daveaglick,

I'm a Statiq.Web license holder actively building my site with the framework. While investigating this issue, I dug into the codebase and found it well-structured and approachable.

I noticed there's a backlog of open PRs dating back over a year, including some dependabot security updates and .NET 8/9 upgrades. I'd be happy to help with maintenance if you're interested - reviewing PRs, triaging issues, keeping dependencies updated, etc.

No pressure either way - just wanted to offer since I'm actively using the project and now have some context from this PR work.

Best,
Bobby Johnson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add CLI flag to disable interactive console/REPL mode

2 participants