Skip to content

ReplApp

DI-enabled REPL application facade for common hosting scenarios.

public sealed class ReplApp : IReplApp, ICoreReplApp, IReplMap
  • 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>)

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)

IContextBuilder

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)

IContextBuilder

Creates a DI-enabled REPL application.

public static ReplApp Create()

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)
  • prepared (PreparedReplStartup): Prepared options and declarations.
  • configureServices (Action<IServiceCollection>): Optional service registration callback.

ReplApp - A new application with a lazily constructed provider.

Creates a DI-enabled REPL application and configures services.

public static ReplApp Create(Action<IServiceCollection> configureServices)
  • configureServices (Action<IServiceCollection>): Service registration callback.

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)
  • serviceProvider (IServiceProvider): Provider used to determine whether direct handler parameters can be omitted.
  • targetPath (string): Optional target path to scope the model.

ReplDocumentationModel - A structured documentation model.

Builds a structured documentation model of the command graph.

public ReplDocumentationModel CreateDocumentationModel(string? targetPath = null)
  • targetPath (string): Optional target path to scope the model. When null, returns the full model. When specified and not found, returns an empty model.

ReplDocumentationModel - A structured documentation model.

Invalidates active routing cache so module presence predicates are re-evaluated on next resolution.

public void InvalidateRouting()

Maps a route and command handler.

public CommandBuilder Map(string route, Delegate handler)

CommandBuilder

Maps a module instance.

public ReplApp MapModule(IReplModule module)

ReplApp

Maps a module instance with an injectable runtime presence predicate.

public ReplApp MapModule(IReplModule module, Delegate isPresent)

ReplApp

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)
  • module (IReplModule)
  • isPresent (Func<ModulePresenceContext, bool>)

ReplApp

Maps a module resolved through runtime DI activation.

public ReplApp MapModule<TModule>() where TModule : class, IReplModule
  • TModule

ReplApp

Configures application options.

public ReplApp Options(Action<ReplOptions> configure)
  • configure (Action<ReplOptions>)

ReplApp

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)

int

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)

int

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)

int

Runs using internally configured services and owns process signals according to ReplRunOptions.

public int Run(string[] args, ReplRunOptions? options = null)

int

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)

int

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)
  • 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.

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)
  • 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.

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)
  • 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.

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)
  • 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.

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)
  • 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.

ValueTask<int>

Runs using internally configured services and owns process signals according to ReplRunOptions.

public ValueTask<int> RunAsync(string[] args, CancellationToken cancellationToken)
  • 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.

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)
  • middleware (Func<ReplExecutionContext, ReplNext, ValueTask>)

ReplApp

Adds an ordered hook after preliminary parsing and before final validation.

public ReplApp UseInvocationHook(Delegate hook)
  • hook (Delegate): Delegate receiving context, command values, options, services or cancellation.

ReplApp - The application.

Adds a startup hook, run once per run before dispatch, including help and completion.

public ReplApp UseStartupHook(Delegate hook)
  • hook (Delegate): Delegate receiving startup context, typed globals and available services.

ReplApp - The application.

Registers a banner delegate rendered at startup after the header line.

public ReplApp WithBanner(Delegate bannerProvider)

ReplApp

Registers a static banner string rendered at startup after the header line.

public ReplApp WithBanner(string text)

ReplApp

Sets an application description for discovery and banner usage.

public ReplApp WithDescription(string text)

ReplApp

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; }

IServiceProvider