ReplApp
DI-enabled REPL application facade for common hosting scenarios.
- Kind:
Class - Namespace: Repl
- Assembly:
Repl.Defaults - Source: src/Repl.Defaults/ReplApp.cs
Signature
Section titled “Signature”public sealed class ReplApp : IReplApp, ICoreReplApp, IReplMapInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Extension Methods
Section titled “Extension Methods”BuildMcpServerOptions(ICoreReplApp, Action<ReplMcpServerOptions>, IServiceProvider)UseGlobalOptions<T>(ReplApp)BuildMcpServerOptions(ReplApp, Action<ReplMcpServerOptions>)UseMcpServer(ReplApp, Action<ReplMcpServerOptions>)UseDocumentationExport(ReplApp, Action<DocumentationExportOptions>)UseCliProfile(ReplApp)UseDefaultInteractive(ReplApp)UseEmbeddedConsoleProfile(ReplApp)UseSpectreConsole(ReplApp, Action<SpectreConsoleOptions>)
Methods
Section titled “Methods”Context(string, Action<IReplApp>, Delegate?)
Section titled “Context(string, Action<IReplApp>, Delegate?)”Creates a top-level context segment and configures nested routes.
public IContextBuilder Context(string segment, Action<IReplApp> configure, Delegate? validation = null)Parameters
Section titled “Parameters”Returns
Section titled “Returns”Context(string, Action<IReplMap>, Delegate?)
Section titled “Context(string, Action<IReplMap>, Delegate?)”Creates a top-level context segment and configures nested routes. Compatibility overload for IReplMap callbacks.
public IContextBuilder Context(string segment, Action<IReplMap> configure, Delegate? validation = null)Parameters
Section titled “Parameters”Returns
Section titled “Returns”Create()
Section titled “Create()”Creates a DI-enabled REPL application.
public static ReplApp Create()Returns
Section titled “Returns”ReplApp - A new ReplApp instance.
Create(Action<IServiceCollection>)
Section titled “Create(Action<IServiceCollection>)”Creates a DI-enabled REPL application and configures services.
public static ReplApp Create(Action<IServiceCollection> configureServices)Parameters
Section titled “Parameters”configureServices(Action<IServiceCollection>): Service registration callback.
Returns
Section titled “Returns”ReplApp - A new ReplApp instance.
CreateDocumentationModel(string?)
Section titled “CreateDocumentationModel(string?)”Builds a structured documentation model of the command graph.
public ReplDocumentationModel CreateDocumentationModel(string? targetPath = null)Parameters
Section titled “Parameters”targetPath(string): Optional target path to scope the model. Whennull, returns the full model. When specified and not found, returns an empty model.
Returns
Section titled “Returns”ReplDocumentationModel - A structured documentation model.
InvalidateRouting()
Section titled “InvalidateRouting()”Invalidates active routing cache so module presence predicates are re-evaluated on next resolution.
public void InvalidateRouting()Map(string, Delegate)
Section titled “Map(string, Delegate)”Maps a route and command handler.
public CommandBuilder Map(string route, Delegate handler)Parameters
Section titled “Parameters”Returns
Section titled “Returns”MapModule(IReplModule)
Section titled “MapModule(IReplModule)”Maps a module instance.
public ReplApp MapModule(IReplModule module)Parameters
Section titled “Parameters”module(IReplModule)
Returns
Section titled “Returns”MapModule(IReplModule, Delegate)
Section titled “MapModule(IReplModule, Delegate)”Maps a module instance with an injectable runtime presence predicate.
public ReplApp MapModule(IReplModule module, Delegate isPresent)Parameters
Section titled “Parameters”module(IReplModule)isPresent(Delegate)
Returns
Section titled “Returns”MapModule(IReplModule, Func<ModulePresenceContext, bool>)
Section titled “MapModule(IReplModule, Func<ModulePresenceContext, bool>)”Maps a module instance with a runtime presence predicate.
public ReplApp MapModule(IReplModule module, Func<ModulePresenceContext, bool> isPresent)Parameters
Section titled “Parameters”module(IReplModule)isPresent(Func<ModulePresenceContext, bool>)
Returns
Section titled “Returns”MapModule<TModule>()
Section titled “MapModule<TModule>()”Maps a module resolved through runtime DI activation.
public ReplApp MapModule<TModule>() where TModule : class, IReplModuleType Parameters
Section titled “Type Parameters”TModule
Returns
Section titled “Returns”Options(Action<ReplOptions>)
Section titled “Options(Action<ReplOptions>)”Configures application options.
public ReplApp Options(Action<ReplOptions> configure)Parameters
Section titled “Parameters”configure(Action<ReplOptions>)
Returns
Section titled “Returns”Run(string[], IHost, ReplRunOptions?)
Section titled “Run(string[], IHost, ReplRunOptions?)”Runs using an externally managed host.
public int Run(string[] args, IHost host, ReplRunOptions? options = null)Parameters
Section titled “Parameters”args(string[])host(IHost)options(ReplRunOptions)
Returns
Section titled “Returns”Run(string[], IReplHost, ReplRunOptions?)
Section titled “Run(string[], IReplHost, ReplRunOptions?)”Runs against an externally managed input/output host.
public int Run(string[] args, IReplHost host, ReplRunOptions? options = null)Parameters
Section titled “Parameters”args(string[])host(IReplHost)options(ReplRunOptions)
Returns
Section titled “Returns”Run(string[], IReplHost, IServiceProvider, ReplRunOptions?)
Section titled “Run(string[], IReplHost, IServiceProvider, ReplRunOptions?)”Runs against an externally managed input/output host with an external service provider.
public int Run(string[] args, IReplHost host, IServiceProvider services, ReplRunOptions? options = null)Parameters
Section titled “Parameters”args(string[])host(IReplHost)services(IServiceProvider)options(ReplRunOptions)
Returns
Section titled “Returns”Run(string[], ReplRunOptions?)
Section titled “Run(string[], ReplRunOptions?)”Runs using internally configured services.
public int Run(string[] args, ReplRunOptions? options = null)Parameters
Section titled “Parameters”args(string[])options(ReplRunOptions)
Returns
Section titled “Returns”Run(string[], IServiceProvider, ReplRunOptions?)
Section titled “Run(string[], IServiceProvider, ReplRunOptions?)”Runs using an externally managed service provider.
public int Run(string[] args, IServiceProvider services, ReplRunOptions? options = null)Parameters
Section titled “Parameters”args(string[])services(IServiceProvider)options(ReplRunOptions)
Returns
Section titled “Returns”RunAsync(string[], IHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], IHost, ReplRunOptions?, CancellationToken)”Runs using an externally managed host.
public ValueTask<int> RunAsync(string[] args, IHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[])host(IHost)options(ReplRunOptions)cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], IReplHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], IReplHost, ReplRunOptions?, CancellationToken)”Runs against an externally managed input/output host.
public ValueTask<int> RunAsync(string[] args, IReplHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[])host(IReplHost)options(ReplRunOptions)cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], IReplHost, IServiceProvider, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], IReplHost, IServiceProvider, ReplRunOptions?, CancellationToken)”Runs against an externally managed input/output host with an external service provider.
public ValueTask<int> RunAsync(string[] args, IReplHost host, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[])host(IReplHost)services(IServiceProvider)options(ReplRunOptions)cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], ReplRunOptions?, CancellationToken)”Runs using internally configured services.
public ValueTask<int> RunAsync(string[] args, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[])options(ReplRunOptions)cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], IServiceProvider, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], IServiceProvider, ReplRunOptions?, CancellationToken)”Runs using an externally managed service provider.
public ValueTask<int> RunAsync(string[] args, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[])services(IServiceProvider)options(ReplRunOptions)cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], CancellationToken)
Section titled “RunAsync(string[], CancellationToken)”Runs using internally configured services.
public ValueTask<int> RunAsync(string[] args, CancellationToken cancellationToken)Parameters
Section titled “Parameters”args(string[])cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
Use(Func<ReplExecutionContext, ReplNext, ValueTask>)
Section titled “Use(Func<ReplExecutionContext, ReplNext, ValueTask>)”Registers middleware in the execution pipeline.
public ReplApp Use(Func<ReplExecutionContext, ReplNext, ValueTask> middleware)Parameters
Section titled “Parameters”middleware(Func<ReplExecutionContext, ReplNext, ValueTask>)
Returns
Section titled “Returns”WithBanner(Delegate)
Section titled “WithBanner(Delegate)”Registers a banner delegate rendered at startup after the header line.
public ReplApp WithBanner(Delegate bannerProvider)Parameters
Section titled “Parameters”bannerProvider(Delegate)
Returns
Section titled “Returns”WithBanner(string)
Section titled “WithBanner(string)”Registers a static banner string rendered at startup after the header line.
public ReplApp WithBanner(string text)Parameters
Section titled “Parameters”text(string)
Returns
Section titled “Returns”WithDescription(string)
Section titled “WithDescription(string)”Sets an application description for discovery and banner usage.
public ReplApp WithDescription(string text)Parameters
Section titled “Parameters”text(string)
Returns
Section titled “Returns”Properties
Section titled “Properties”Services
Section titled “Services”Returns the shared service provider, building it on first access. This provider is reused for both module resolution and runtime execution, ensuring DI-resolved modules share the same service instances as handlers.
public IServiceProvider Services { get; }