Skip to content

REPL Mode

When you run your app with no arguments, Repl starts an interactive session. The same routes your CLI uses are available interactively — no separate implementation.

Terminal window
$ myapp
>

The > prompt signals REPL mode. Type any command from your graph:

> client list
Alice
Bob
> client 42 show --json
{ "id": 42, "name": "ACME" }
> exit

app.Context(...) creates sub-scopes. You can enter a scope and run commands relative to it:

> client
[client]> list
Alice
Bob
[client]> 42
[client/42]> show
Id: 42, Name: ACME
[client/42]> ..
[client]> ..
>
  • Enter a scope by typing its name (or a scoped value like 42).
  • Go up with ...
  • The prompt shows your current position.

These are always available in REPL mode regardless of your command graph:

CommandDescription
helpList commands in current scope
help <route>Describe a specific command
exitEnd the session
clearClear the screen
..Go up one scope level
  • Up/Down arrows navigate command history.
  • Tab triggers autocomplete for routes and parameters (requires UseDefaultInteractive()).
  • History is in-memory by default and does not persist across sessions. Inject a custom IHistoryProvider to add persistence (file, database, or any backing store).
app.WithBanner("""
Welcome to MyApp REPL.
Type 'help' to list commands.
""");

REPL mode can be driven by a script using --answer:* options — useful for demos and deterministic testing:

Terminal window
myapp --answer:1=Alice --answer:2=alice@example.com

The --answer:N flag pre-fills interactive prompts in order.

MCP Mode