Skip to content

Add CLI flag to disable interactive console/REPL mode #283

@NotMyself

Description

@NotMyself

Summary

The preview command (and potentially interactive command) launches an interactive REPL console that requires a valid console handle. This prevents running the preview server in non-interactive contexts such as:

  • CI/CD pipelines
  • Background processes
  • IDE integrations (e.g., Claude Code, VS Code tasks)
  • Containerized environments
  • Any automated tooling

Current Behavior

When running dotnet run -- preview, the server starts successfully but then fails with:

[INFO] Preview server listening at http://localhost:5080
[INFO] Type Ctrl-C or "Exit()" to exit and "Help()" for global methods and properties
> Error: The handle is invalid.

This happens because the REPL attempts to interact with stdin/stdout handles that aren't available in non-interactive contexts.

Proposed Solution

Add a CLI flag such as --no-interactive or --headless to disable the REPL while keeping the preview server running:

dotnet run -- preview --no-interactive

This would allow the preview server to run in daemon/background mode without requiring console interaction.

Alternatives Considered

  • Using serve command separately (requires two-step build then serve)
  • Spawning in a new terminal window (platform-specific workaround)
  • Piping empty stdin (doesn't reliably work)

Environment

  • Statiq.Web 1.0.0
  • .NET 8.0
  • Windows 11 (but issue likely affects all platforms in non-interactive contexts)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions