Skip to content

CLI Mode

When you pass arguments to your app, Repl dispatches the command and exits — standard CLI behavior.

Terminal window
myapp <route> [arguments] [options]

Examples:

Terminal window
myapp client list
myapp client 42 show
myapp client 42 show --json

Every command supports output format flags out of the box:

FlagOutput
(none)Human-readable text / table
--jsonJSON
--xmlXML
--yamlYAML
--markdownMarkdown table
Terminal window
$ myapp contacts list --json
[
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]

--help is built in at every level:

Terminal window
$ myapp --help
Commands:
client
report
$ myapp client --help
Commands:
client list
client {id} show
client {id} remove

Register Repl’s completion scripts to get tab completion in your shell:

Terminal window
# Auto-detect current shell
myapp completion install
# Explicit shell
myapp completion install --shell bash
myapp completion install --shell powershell
myapp completion install --shell zsh
myapp completion install --shell fish
myapp completion install --shell nu # Nushell

This writes a managed block to the shell’s profile file. Tab completion then works for all routes, context segments, and option names.

Other commands:

Terminal window
myapp completion status # show current installation status
myapp completion uninstall # remove the managed block
myapp completion detect-shell # show which shell was detected

The completion bridge (completion __complete) is hidden from --help — it is a protocol command used by the shell scripts.

Automatic installation — configure how completion is offered at startup:

SetupModeBehavior
Manual (default)User runs install explicitly
PromptOffers installation once on the first interactive startup
AutoInstalls automatically when a supported shell is detected
app.Options(o =>
{
o.ShellCompletion.SetupMode = CompletionSetupMode.Prompt;
});

Any argument prefixed with @ is a response file:

Terminal window
myapp @deploy.rsp

deploy.rsp:

deploy
--environment
production
--region
us-east-1

Tokens are read one per line. Useful for long or repeatable invocations, and for passing arguments in CI without quoting issues. Response files are not recursive.

Add --help --json to get a structured help payload — useful for agents and tooling:

Terminal window
$ myapp client --help --json
{
"name": "client",
"commands": [
{ "route": "list", "description": "..." },
{ "route": "{id:int} show", "description": "..." }
]
}
ConditionExit code
Success0
All named errors — command not found, validation failure, cancellation, unhandled exception1
Custom (explicit)any N — use Results.Exit(N) in a handler to return an arbitrary code

All error conditions produce exit code 1 by default. To signal a specific failure mode to callers or scripts, return Results.Exit(N) from your handler with the code that makes sense for your application.

REPL Mode