Command Line Tooling
JasperFx includes a lightweight CLI framework for building commands that integrate with Microsoft.Extensions.Hosting.
Enabling the CLI
Wire up the JasperFx command line by calling ApplyJasperFxExtensions on your host builder:
await Host
.CreateDefaultBuilder()
.ApplyJasperFxExtensions()
.RunJasperFxCommands(args);await Host
.CreateDefaultBuilder()
.ApplyJasperFxExtensions()
.RunJasperFxCommands(args);Alternatively, use RunJasperFxCommands for more control over host configuration:
var builder = Host.CreateDefaultBuilder();
builder.ConfigureServices(services =>
{
// Register your services here
});
await builder
.ApplyJasperFxExtensions()
.RunJasperFxCommands(args);var builder = Host.CreateDefaultBuilder();
builder.ConfigureServices(services =>
{
// Register your services here
});
await builder
.ApplyJasperFxExtensions()
.RunJasperFxCommands(args);Built-in Commands
JasperFx ships with several commands out of the box:
| Command | Description |
|---|---|
help | List all available commands |
describe | Describe the application configuration |
check-env | Run all registered environment checks |
Command Discovery
Commands are discovered automatically from referenced assemblies that carry the [JasperFxTool] attribute. Your own commands are found through assembly scanning.
Machine-readable command catalog
help --json writes the command catalog to stdout as JSON — each verb's name and description — for tooling that needs to introspect an app's commands:
dotnet run -- help --json[
{ "name": "check-env", "description": "Execute all environment checks against the application" },
{ "name": "describe", "description": "Writes out a description of your running application ..." }
]Like help itself, this runs without starting the host (no database/broker connections), so it is cheap to call. The Aspire dashboard integration uses it to discover a service's verbs.
Topics
- Writing Commands -- Create synchronous and async commands
- Arguments and Flags -- Define inputs with attributes
- Environment Checks -- Validate runtime dependencies
- Describe -- Customize the describe output
