ReplApp
DI-enabled REPL application facade for common hosting scenarios.
- Kind:
Class - Namespace: Repl
- Assembly:
Repl.Defaults - Source: src/Repl.Defaults/ReplApp.Startup.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)ConfigureMcpServerOptions(ICoreReplApp, McpServerOptions, Action<ReplMcpServerOptions>, IServiceProvider)UseGlobalOptions<T>(ReplApp)UseArgumentPreprocessor(ReplApp, Func<ArgumentPreprocessingContext, CancellationToken, ArgumentPreprocessingResult>)UseArgumentPreprocessor(ReplApp, Func<ArgumentPreprocessingContext, CancellationToken, ValueTask<ArgumentPreprocessingResult>>)UseInputValidator(ReplApp, Delegate)UseDocumentationExport(ReplApp, Action<DocumentationExportOptions>)UseCliProfile(ReplApp)UseDefaultInteractive(ReplApp)UseEmbeddedConsoleProfile(ReplApp)UseTerminalIntegration(ReplApp, Action<TerminalIntegrationOptions>)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(PreparedReplStartup, Action<IServiceCollection>?)
Section titled “Create(PreparedReplStartup, Action<IServiceCollection>?)”Creates an application after successful preparation, then configures application services.
public static ReplApp Create(PreparedReplStartup prepared, Action<IServiceCollection>? configureServices = null)Parameters
Section titled “Parameters”prepared(PreparedReplStartup): Prepared options and declarations.configureServices(Action<IServiceCollection>): Optional service registration callback.
Returns
Section titled “Returns”ReplApp - A new application with a lazily constructed provider.
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(IServiceProvider, string?)
Section titled “CreateDocumentationModel(IServiceProvider, string?)”Builds a structured documentation model using an externally managed provider for service-backed parameters.
public ReplDocumentationModel CreateDocumentationModel(IServiceProvider serviceProvider, string? targetPath = null)Parameters
Section titled “Parameters”serviceProvider(IServiceProvider): Provider used to determine whether direct handler parameters can be omitted.targetPath(string): Optional target path to scope the model.
Returns
Section titled “Returns”ReplDocumentationModel - A structured documentation model.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
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 and owns process signals according to ReplRunOptions.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
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(PreparedReplStartup, IHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(PreparedReplStartup, IHost, ReplRunOptions?, CancellationToken)”Runs prepared input in a caller-owned generic host.
public ValueTask<int> RunAsync(PreparedReplStartup prepared, IHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”prepared(PreparedReplStartup): Prepared input.host(IHost): Caller-owned host.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(PreparedReplStartup, IReplHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(PreparedReplStartup, IReplHost, ReplRunOptions?, CancellationToken)”Runs prepared input with externally managed input and output.
public ValueTask<int> RunAsync(PreparedReplStartup prepared, IReplHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”prepared(PreparedReplStartup): Prepared input.host(IReplHost): Input/output host.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(PreparedReplStartup, IReplHost, IServiceProvider, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(PreparedReplStartup, IReplHost, IServiceProvider, ReplRunOptions?, CancellationToken)”Runs prepared input with externally managed input, output and services.
public ValueTask<int> RunAsync(PreparedReplStartup prepared, IReplHost host, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”prepared(PreparedReplStartup): Prepared input.host(IReplHost): Input/output host.services(IServiceProvider): Caller-owned service provider.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(PreparedReplStartup, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(PreparedReplStartup, ReplRunOptions?, CancellationToken)”Runs prepared input using the application’s services.
public ValueTask<int> RunAsync(PreparedReplStartup prepared, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”prepared(PreparedReplStartup): Input prepared for the application’s builder.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(PreparedReplStartup, IServiceProvider, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(PreparedReplStartup, IServiceProvider, ReplRunOptions?, CancellationToken)”Runs prepared input with caller-owned services.
public ValueTask<int> RunAsync(PreparedReplStartup prepared, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”prepared(PreparedReplStartup): Prepared input.services(IServiceProvider): Caller-owned service provider.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(ReplInvocationRequest, IHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(ReplInvocationRequest, IHost, ReplRunOptions?, CancellationToken)”Runs a structured request in a caller-owned generic host.
public ValueTask<int> RunAsync(ReplInvocationRequest request, IHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”request(ReplInvocationRequest): Invocation target and values.host(IHost): Caller-owned host.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(ReplInvocationRequest, IReplHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(ReplInvocationRequest, IReplHost, ReplRunOptions?, CancellationToken)”Runs a structured request with externally managed input and output.
public ValueTask<int> RunAsync(ReplInvocationRequest request, IReplHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”request(ReplInvocationRequest): Invocation target and values.host(IReplHost): Input/output host.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(ReplInvocationRequest, IReplHost, IServiceProvider, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(ReplInvocationRequest, IReplHost, IServiceProvider, ReplRunOptions?, CancellationToken)”Runs a structured request with externally managed input, output and services.
public ValueTask<int> RunAsync(ReplInvocationRequest request, IReplHost host, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”request(ReplInvocationRequest): Invocation target and values.host(IReplHost): Input/output host.services(IServiceProvider): Caller-owned services.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(ReplInvocationRequest, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(ReplInvocationRequest, ReplRunOptions?, CancellationToken)”Runs a textual or native structured request using application services.
public ValueTask<int> RunAsync(ReplInvocationRequest request, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”request(ReplInvocationRequest): Invocation target and values.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(ReplInvocationRequest, IServiceProvider, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(ReplInvocationRequest, IServiceProvider, ReplRunOptions?, CancellationToken)”Runs a structured request with caller-owned services.
public ValueTask<int> RunAsync(ReplInvocationRequest request, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”request(ReplInvocationRequest): Invocation target and values.services(IServiceProvider): Caller-owned services.options(ReplRunOptions): Run options.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(ReplInvocationRequest, CancellationToken)
Section titled “RunAsync(ReplInvocationRequest, CancellationToken)”Runs a textual or native structured request using application services.
public ValueTask<int> RunAsync(ReplInvocationRequest request, CancellationToken cancellationToken)Parameters
Section titled “Parameters”request(ReplInvocationRequest): Invocation target and values.cancellationToken(CancellationToken): Caller cancellation.
Returns
Section titled “Returns”ValueTask<int> - The process exit code.
RunAsync(string[], IHost, ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], IHost, ReplRunOptions?, CancellationToken)”Runs using an externally managed host; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
public ValueTask<int> RunAsync(string[] args, IHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[]): Command-line arguments.host(IHost): Caller-owned application host.options(ReplRunOptions): Per-run options. An explicit Automatic request is diagnosed and ignored because this overload is externally owned.cancellationToken(CancellationToken): Caller-owned cancellation token. This overload does not install a standalone process-signal bridge or create a signal-linked token.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
public ValueTask<int> RunAsync(string[] args, IReplHost host, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[]): Command-line arguments.host(IReplHost): Caller-owned input/output host.options(ReplRunOptions): Per-run options. An explicit Automatic request is diagnosed and ignored because this overload is externally owned.cancellationToken(CancellationToken): Caller-owned cancellation token. This overload does not install a standalone process-signal bridge or create a signal-linked token.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
public ValueTask<int> RunAsync(string[] args, IReplHost host, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[]): Command-line arguments.host(IReplHost): Caller-owned input/output host.services(IServiceProvider): Caller-owned service provider.options(ReplRunOptions): Per-run options. An explicit Automatic request is diagnosed and ignored because this overload is externally owned.cancellationToken(CancellationToken): Caller-owned cancellation token. This overload does not install a standalone process-signal bridge or create a signal-linked token.
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], ReplRunOptions?, CancellationToken)
Section titled “RunAsync(string[], ReplRunOptions?, CancellationToken)”Runs using internally configured services and owns process signals according to ReplRunOptions.
public ValueTask<int> RunAsync(string[] args, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[]): Command-line arguments.options(ReplRunOptions): Per-run options. A null signal-handling value inherits the active profile.cancellationToken(CancellationToken): Caller-owned cancellation token. Automatic signal mode injects a linked, run-scoped token; caller-owned mode passes this token through directly.
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; standalone signal bridging and cancellation remain caller-owned. Interactive mode retains its own Ctrl+C policy.
public ValueTask<int> RunAsync(string[] args, IServiceProvider services, ReplRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”args(string[]): Command-line arguments.services(IServiceProvider): Caller-owned service provider.options(ReplRunOptions): Per-run options. An explicit Automatic request is diagnosed and ignored because this overload is externally owned.cancellationToken(CancellationToken): Caller-owned cancellation token. This overload does not install a standalone process-signal bridge or create a signal-linked token.
Returns
Section titled “Returns”ValueTask<int>
RunAsync(string[], CancellationToken)
Section titled “RunAsync(string[], CancellationToken)”Runs using internally configured services and owns process signals according to ReplRunOptions.
public ValueTask<int> RunAsync(string[] args, CancellationToken cancellationToken)Parameters
Section titled “Parameters”args(string[]): Command-line arguments.cancellationToken(CancellationToken): Caller-owned cancellation token. Automatic signal mode injects a linked, run-scoped token; caller-owned mode passes this token through directly.
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”UseInvocationHook(Delegate)
Section titled “UseInvocationHook(Delegate)”Adds an ordered hook after preliminary parsing and before final validation.
public ReplApp UseInvocationHook(Delegate hook)Parameters
Section titled “Parameters”hook(Delegate): Delegate receiving context, command values, options, services or cancellation.
Returns
Section titled “Returns”ReplApp - The application.
UseStartupHook(Delegate)
Section titled “UseStartupHook(Delegate)”Adds a startup hook, run once per run before dispatch, including help and completion.
public ReplApp UseStartupHook(Delegate hook)Parameters
Section titled “Parameters”hook(Delegate): Delegate receiving startup context, typed globals and available services.
Returns
Section titled “Returns”ReplApp - The application.
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; }