Skip to content

SpectreReplExtensions

Extension methods to enable Spectre.Console integration in a Repl application.

public static class SpectreReplExtensions

Registers Spectre.Console services: SpectreInteractionHandler for rich prompts and IAnsiConsole for direct injection into commands. In an externally managed container (the AddRepl pattern), the registered services resolve the app’s terminal detection through the ReplApp registered in that container; an explicit options registration in the container always wins, and a container holding several apps should register options explicitly.

public static IServiceCollection AddSpectreConsole(this IServiceCollection services)

IServiceCollection - The same service collection for chaining.

UseSpectreConsole(ReplApp, Action<SpectreConsoleOptions>?)

Section titled “UseSpectreConsole(ReplApp, Action<SpectreConsoleOptions>?)”

Enables Spectre.Console output rendering by registering the “spectre” output transformer and setting it as the default format. Also registers the SpectreInteractionHandler and IAnsiConsole DI service.

public static ReplApp UseSpectreConsole(this ReplApp app, Action<SpectreConsoleOptions>? configure = null)
  • app (ReplApp): Target REPL application.
  • configure (Action<SpectreConsoleOptions>): Optional callback to configure Spectre console options.

ReplApp - The same app instance for chaining.