Terminator is a framework for building user-friendly command-line interfaces (CLIs) in .NET, built on CommandDotNet, Spectre.Console and Microsoft.Extensions.DependencyInjection.
It's designed for creating tools that are easy to use and maintain, especially those that act as a "runner" for other projects.
When a Terminator-based app is run without arguments, it shows an interactive drop-down list of all available commands. This makes the tool's capabilities discoverable without needing to memorize commands.
dotnet add Terminator
dotnet add CommandDotNet
This is enabled by a simple bootstrap process in your Program.cs:
using CommandDotNet;
using Terminator.Builder;
// Initialize the CLI application with your root command class
var app = CliBuilder.Initialize<RootCommand>();
await app.RunAsync(args);
// Define your commands
public class RootCommand
{
[Command]
public void TestCommand()
{
Console.WriteLine("Hello, World!");
}
}Terminator uses Microsoft.Extensions.DependencyInjection to manage services. You can register your own services by creating a class that implements the IServiceRegistrar interface.
using Microsoft.Extensions.DependencyInjection;
using Terminator.DependencyInjection;
// Define your service
public interface IMyService
{
string GetMessage();
}
public class MyService : IMyService
{
public string GetMessage() => "Hello from a service!";
}
// Register your service
public class MyServiceInjections : IServiceRegistrar
{
public void RegisterServices(IServiceCollection services)
{
services.AddSingleton<IMyService, MyService>();
}
}You can then inject your services into your command methods or constructors.
public class RootCommand
{
[Command]
public void TestCommand(IMyService myService)
{
Console.WriteLine(myService.GetMessage());
}
}The templates generate helper scripts to make running your application easy across different platforms.
-
On Linux/macOS: Use the
run.shscript../run.sh
-
On Windows: Use the
run.ps1script with PowerShell../run.ps1
All commands include generated help, which you can access by passing the -h or --help flag.
# Get help for the root command
./run.sh -h
# Get help for a subcommand
./run.sh sub -hThis package comes with templates to get you started with a new Terminator-based CLI application.
dotnet new install Terminator.TemplatesThis template creates a new command-line application with a basic project structure. It includes a root command and an example subcommand, and is pre-configured to use CommandDotNet for argument parsing and dependency injection.
To create a minimal Terminator-based CLI app with dependency injection, run:
dotnet new terminator-simple -n YourAppNameThis template creates a project for build and release automation. The project includes helper scripts (run.sh for Linux/macOS and run.ps1 for Windows) to execute build commands. The project structure is set up for build automation tasks.
To create a new build and release tool, run:
dotnet new terminator-build -n YourBuildToolName