Configuration Reference
App creation
Section titled “App creation”CoreReplApp.Create()
Section titled “CoreReplApp.Create()”Creates a lightweight app with no DI container. Use when you don’t need dependency injection.
var app = CoreReplApp.Create() .WithDescription("My app description") .WithBanner("Welcome message shown in REPL mode");ReplApp.Create()
Section titled “ReplApp.Create()”Creates an app with a default DI container (Microsoft.Extensions.DependencyInjection).
var app = ReplApp.Create().UseDefaultInteractive();Pass a service configuration delegate to ReplApp.Create() to register services before the app runs:
var app = ReplApp.Create(services =>{ services.AddSingleton<IMyService, MyService>();}).UseDefaultInteractive();Profiles
Section titled “Profiles”A profile is a preset: one call that applies a few options for a hosting situation. Profiles are extension methods on ReplApp from Repl.Defaults; CoreReplApp has none.
What each profile changes
Section titled “What each profile changes”| No profile | UseDefaultInteractive() | UseCliProfile() | UseEmbeddedConsoleProfile() | |
|---|---|---|---|---|
Ctrl+C or SIGTERM during a one-shot Run(args) | Left to the caller | Repl cancels the handler, exits 130 or 143 | Repl cancels the handler, exits 130 or 143 | Left to the caller |
The exit command | Available | Available | Available | Disabled: hidden from help, and typing it prints an error |
Every profile also assigns InteractivePolicy.Auto, and restates a few defaults: the > prompt for UseDefaultInteractive(), human output and the banner for UseCliProfile(). In 0.12, called first, UseDefaultInteractive() and UseCliProfile() therefore behave the same; pick the name that states your intent.
Everything else is the same with or without a profile: myapp with no arguments opens the REPL, Tab completes, history works, and Ctrl+C in the REPL cancels the running command and keeps the session open.
UseDefaultInteractive() and UseCliProfile()
Section titled “UseDefaultInteractive() and UseCliProfile()”For an app that runs as its own process and calls app.RunAsync(args) without a service provider or host. Repl owns Ctrl+C and SIGTERM during a one-shot run: the handler’s token is cancelled, and the process exits 130 or 143, which scripts and supervisors can tell apart from a failure. See Exit Codes & Signals.
UseDefaultInteractive()reads well for a tool people both explore and script: an operations console, a developer utility, an admin tool for a service.myappopens the REPL to browse contexts;myapp client 42 showruns one command and exits.UseCliProfile()reads well for a process run from a shell, a script, CI or a service manager: a .NET global tool, a deployment step, a container health probe. AddInteractivePolicy.Prevent, as shown above, ifmyappalone should print the help instead of opening the REPL.
var app = ReplApp.Create().UseDefaultInteractive();UseEmbeddedConsoleProfile()
Section titled “UseEmbeddedConsoleProfile()”For a command graph that runs inside a host that owns the process, such as a worker service, a test runner or another command framework that calls app.RunAsync(args, ct) itself. The host keeps its signals and its shutdown. The RunAsync overloads that take an IServiceProvider or an IHost already leave signals to the caller under every profile.
It is also the profile of the WebSocket and Telnet and remote administration samples. Those sessions run through an IReplHost, which also leaves signals to the caller under any profile, so there the profile’s effect is the disabled exit command: users leave by closing the connection, or with Ctrl+D in a remote console. Set o.AmbientCommands.ExitCommandEnabled = true after the profile to bring exit back.
builder.Services.AddRepl((_, repl) =>{ repl.UseEmbeddedConsoleProfile(); repl.Map("status", () => "ok");});Do I need one, and can I combine them?
Section titled “Do I need one, and can I combine them?”No: without one you get the No profile column above.
Profiles can be chained: each call assigns its options in order, and the last one wins where they overlap. Several repository samples chain UseDefaultInteractive().UseCliProfile(); in 0.12 the second call adds nothing the first does not already set. UseEmbeddedConsoleProfile() contradicts the other two on signal ownership, so use it alone.
Call the profile first, before app.Options(...) and other Use* extensions. A profile called later assigns its values again: InteractivePolicy returns to Auto, and UseCliProfile() resets the default output format that UseSpectreConsole() sets to spectre.
Route registration
Section titled “Route registration”Map(route, handler)
Section titled “Map(route, handler)”app.Map("greet {name}", (string name) => $"Hello, {name}!");- Route parameters:
{name},{id:int},{email:email},{token:guid}, etc. - Handler can be a delegate, method group, or lambda.
- Parameters are bound from route segments + DI.
Context(segment, configure)
Section titled “Context(segment, configure)”app.Context("admin", admin =>{ admin.Map("list-users", ...);});Fluent modifiers on routes
Section titled “Fluent modifiers on routes”| Method | Effect |
|---|---|
.WithDescription("...") | Sets the command description shown in help |
.Destructive() / .ReadOnly() / .Idempotent() | MCP behavioral annotations |
.AutomationHidden() | Hides from MCP agents; visible in interactive REPL |
.AsResource() | Registers as an MCP resource (URI derived from route) |
.AsPrompt() | Registers as an MCP prompt template |
.AsMcpAppResource() | Registers as an MCP Apps UI resource |
.WithCompletion(targetName, provider[, scope]) | Registers Tab completion for the named parameter or option. The optional CompletionProviderScope (default Interactive) opts the provider into shell completion (InteractiveAndShell) |
Parameters
Section titled “Parameters”Route constraints
Section titled “Route constraints”| Constraint | .NET type |
|---|---|
{x:int} | int |
{x:long} | long |
{x:double} | double |
{x:bool} | bool |
{x:guid} | Guid |
{x:email} | string (validated) |
{x:date} / {x:dateonly} | DateOnly |
{x:datetime} / {x:date-time} | DateTime |
{x:datetimeoffset} / {x:date-time-offset} | DateTimeOffset |
{x:time} / {x:timeonly} | TimeOnly |
{x:timespan} / {x:time-span} | TimeSpan |
Types are also inferred from the handler parameter type, so :int is implicit when the parameter is int id. For all accepted input formats, see Built-in Types & Formats.
Options groups
Section titled “Options groups”[ReplOptionsGroup]public class PagingOptions{ [ReplOption(Aliases = ["--limit"])] public int Limit { get; init; } = 20;
[ReplOption(Aliases = ["--sort"])] public string Sort { get; init; } = "name";}Handlers that accept PagingOptions receive all flags in the group. Avoid names already reserved by Repl: --format, --json, --xml, --yaml, --markdown, --no-logo, --help, --interactive, --no-interactive, --output, and --answer:*.
Temporal ranges
Section titled “Temporal ranges”Three range types, one per precision level:
| Type | Precision | Duration constraint |
|---|---|---|
ReplDateRange | DateOnly | Whole days only |
ReplDateTimeRange | DateTime | Any duration |
ReplDateTimeOffsetRange | DateTimeOffset | Any duration |
Both start..end and start@duration forms are accepted. See Built-in Types & Formats for all format details.
Interactive options
Section titled “Interactive options”| Flag (CLI) | Effect |
|---|---|
--json | Output as JSON |
--xml | Output as XML |
--yaml | Output as YAML |
--markdown | Output as Markdown table |
--help | Show help for this route |
--help --json | Machine-readable help |
--answer:N=value | Pre-fill the Nth interactive prompt |