SpectreReplExtensions
Extension methods to enable Spectre.Console integration in a Repl application.
- Kind:
Class - Namespace: Repl.Spectre
- Assembly:
Repl.Spectre - Source: src/Repl.Spectre/SpectreReplExtensions.cs
Signature
Section titled “Signature”public static class SpectreReplExtensionsInheritance
Section titled “Inheritance”Methods
Section titled “Methods”AddSpectreConsole(IServiceCollection)
Section titled “AddSpectreConsole(IServiceCollection)”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)Parameters
Section titled “Parameters”services(IServiceCollection): Target service collection.
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”app(ReplApp): Target REPL application.configure(Action<SpectreConsoleOptions>): Optional callback to configure Spectre console options.
Returns
Section titled “Returns”ReplApp - The same app instance for chaining.