Terminator.Templates
1.4.0
dotnet new install Terminator.Templates@1.4.0
Terminator
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.
Terminator targets every currently supported .NET release (.NET 8, 9, 10 and 11). The templates target the latest stable release.
For the full API walkthrough, see the guide.
Minimal example
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 new console
dotnet add package Terminator
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!");
}
}
Dependency injection
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());
}
}
More features
The guide covers each of these with examples:
- Live activity tracking:
CliTracker,ActivityScopeandActivityObservationTablerender a live progress table for multi-step operations. - Shell commands: run CliWrap commands bound to an
ActivityScope, with stdout and stderr logged automatically. - Release helpers:
GitHelper,VersionHelper,NuGetHelper,NpmPublishHelperandGithubTokenHelperfor build and release tools. - Ctrl+C support: prompts and a global cancellation token that respect Ctrl+C.
- Configuration: fall back to
IConfigurationvalues for command arguments.
Running the Application
The templates generate helper scripts to make running your application easy across different platforms.
On Linux/macOS: Use the
run.shscript../run.shOn Windows: Use the
run.ps1script with PowerShell../run.ps1
Getting Help
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 -h
Templates
This package comes with templates to get you started with a new Terminator-based CLI application.
Installation
dotnet new install Terminator.Templates
Simple CLI App
This 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 YourAppName
Build Tool
This 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
Development
dotnet build Terminator.sln
dotnet test --solution Terminator.sln
Every pull request runs CI, which builds, tests, packs, and builds a project generated from each template. Dependabot opens weekly dependency update PRs. See AGENTS.md for the repository layout and conventions.
Security
Please report vulnerabilities privately. See SECURITY.md.
-
net11.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.