BosonWare.TerminalApp
2.2.1
dotnet add package BosonWare.TerminalApp --version 2.2.1
NuGet\Install-Package BosonWare.TerminalApp -Version 2.2.1
<PackageReference Include="BosonWare.TerminalApp" Version="2.2.1" />
<PackageVersion Include="BosonWare.TerminalApp" Version="2.2.1" />
<PackageReference Include="BosonWare.TerminalApp" />
paket add BosonWare.TerminalApp --version 2.2.1
#r "nuget: BosonWare.TerminalApp, 2.2.1"
#:package BosonWare.TerminalApp@2.2.1
#addin nuget:?package=BosonWare.TerminalApp&version=2.2.1
#tool nuget:?package=BosonWare.TerminalApp&version=2.2.1
BosonWare.TerminalApp
BosonWare.TerminalApp is a modern, extensible .NET terminal application framework designed to simplify the creation of interactive command-line tools. It provides a robust command registry, built-in commands, command history, and flexible parsing utilities, making it ideal for building rich terminal experiences.
Features
- Command Registry: Easily register and manage commands with attributes and aliases.
- Built-in Commands: Includes common commands like
help
,clear
,exit
,version
, andtime
. - Command History: Persistent command history with disk storage.
- Command Parsing: Advanced command-line parsing with support for quoted arguments.
- Extensibility: Add custom commands by implementing the
ICommand
interface or deriving fromCommand<TOptions>
. - Colorful Output: Integrates with BosonWare.TUI for styled console output.
Getting Started
Prerequisites
- .NET 8.0 or later
Installation
Add the NuGet package to your project:
dotnet add package BosonWare.TerminalApp
Example Usage
Create a simple terminal app:
using BosonWare.TerminalApp;
using BosonWare.TerminalApp.BuiltIn;
CommandRegistry.LoadCommands<Program>(typeof(IBuiltInAssemblyMarker));
var app = new ConsoleApplication() {
Prompt = "[Crimson]Boson Terminal[/] > ",
History = CommandHistory.CreateAsync("command_history.json").GetAwaiter().GetResult()
};
await app.RunAsync();
Registering Commands
Commands are registered using the [Command]
attribute:
[Command("greet", Aliases = ["hello"], Description = "Greets the user.")]
public sealed class GreetCommand : ICommand
{
public Task Execute(string arguments)
{
Console.WriteLine($"Hello, {arguments}!");
return Task.CompletedTask;
}
}
Or use options parsing:
public class EchoOptions
{
[Option('u', "upper", HelpText = "Uppercase output.")]
public bool Upper { get; set; }
}
[Command("echo", Description = "Echoes input.")]
public sealed class EchoCommand : Command<EchoOptions>
{
public override Task Execute(EchoOptions options)
{
// Implementation here
return Task.CompletedTask;
}
}
Built-in Commands
help
/info
/-h
/?
— Displays helpclear
/cls
— Clears the terminalexit
/shutdown
— Exits the applicationversion
/ver
— Shows version infotime
— Shows current time (--utc
for UTC)
Command History
Command history is persisted to disk and loaded on startup. The default limit is 1000 entries.
License
MIT License. See LICENSE for details.
Contributing
Contributions are welcome! Please submit issues or pull requests via GitHub.
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- BosonWare.Runtime (>= 2.1.0)
- CommandLineParser (>= 2.9.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added support for `GroupAttribute` on interfaces.