triaxis.CommandLine.ObjectOutput
2.6.0
dotnet add package triaxis.CommandLine.ObjectOutput --version 2.6.0
NuGet\Install-Package triaxis.CommandLine.ObjectOutput -Version 2.6.0
<PackageReference Include="triaxis.CommandLine.ObjectOutput" Version="2.6.0" />
<PackageVersion Include="triaxis.CommandLine.ObjectOutput" Version="2.6.0" />
<PackageReference Include="triaxis.CommandLine.ObjectOutput" />
paket add triaxis.CommandLine.ObjectOutput --version 2.6.0
#r "nuget: triaxis.CommandLine.ObjectOutput, 2.6.0"
#:package triaxis.CommandLine.ObjectOutput@2.6.0
#addin nuget:?package=triaxis.CommandLine.ObjectOutput&version=2.6.0
#tool nuget:?package=triaxis.CommandLine.ObjectOutput&version=2.6.0
triaxis.CommandLine
Write a class, get a command. An opinionated layer over
System.CommandLine that
discovers commands with a source generator, binds their arguments and options, resolves
their dependencies, and formats whatever they return — with no Program.cs of your own and
no reflection at runtime.
#!/usr/bin/env -S dotnet --
#:package triaxis.CommandLine.Tool@*
[Command("greet", Description = "Say hello")]
public class GreetCommand : LoggingCommand
{
[Option("--name", "-n")]
private readonly string _name = "World";
public void Execute() => Console.WriteLine($"Hello {_name}!");
}
./hello.cs greet --name Alice # a whole tool in one file, no project, no Main
That is the whole tool: --help, --verbosity, --output, Ctrl+C handling, DI and
configuration come with it.
Install
dotnet new console -n MyTool && cd MyTool
dotnet add package triaxis.CommandLine.Tool
Delete Program.cs. With no entry point of its own, the project gets a generated one
that wires up logging, configuration, object output and command discovery — and omits what
your commands never use. Add a [Command] class anywhere in the assembly and run it.
Getting started walks through the rest: commands and
subcommands, argument and option binding, [Inject] and constructor DI, configuration
files and scopes, and the UseDefaults() one-liner for a hand-written Main.
| Package | Purpose |
|---|---|
triaxis.CommandLine |
Core ToolBuilder, attributes, command discovery, DI |
triaxis.CommandLine.ObjectOutput |
--output formatters (Table/Wide/Json/Yaml/Raw/None) |
triaxis.CommandLine.Serilog |
Serilog integration and --verbosity / -v / -q options |
triaxis.CommandLine.Tool |
Opinionated all-in-one meta-package (UseDefaults()) |
The libraries target netstandard2.0 and netstandard2.1, so they run on any modern .NET
or .NET Framework host. Tools built on top typically target net8.0 or newer.
What you get
| Commands | [Command("db", "migrate")] on a class with Execute/ExecuteAsync. Nested paths become subcommands, and a class can carry several. Discovery is source-generated. |
| Binding | [Argument] and [Option] on fields or properties, public or private; [Options] flattens a nested object; [ActionOption] adds an alternate entry point behind its own flag. |
| Dependency injection | Constructor parameters resolve from the container without registering the command, or use [Inject] on any member. [ConfigureServices] / [Configure] hooks register services without a hand-written Main. |
| Configuration | appsettings.json, machine and per-user overrides, environment variables — layered into precedence scopes, with Update(scope, …) writing one layer back as a minimal edit. |
| Logging | Serilog, created lazily after parsing, so -v / -q / --verbosity and the Serilog config section both apply with no level switch. |
| Output | Return a record, a list, an IAsyncEnumerable or a tuple; --output Table\|Wide\|Json\|Yaml\|Raw\|None formats it. JSON and YAML are emitted in-house, so there is no serializer dependency. |
| Middleware | AddMiddleware(async (context, next) => …) around every invocation, first registered outermost. |
| Errors and Ctrl+C | CommandErrorException (and any type you map to it) exits cleanly with a logged message and your exit code; ExecuteAsync(CancellationToken) gets cooperative shutdown. |
| Own host | A Main/MainAsync command skips the CLI's container and runs its own — ASP.NET Core inside a subcommand, sharing the tool's config and Serilog via ApplyTo. |
| NativeAOT | PublishAot works: 3.38 MiB for a command-only tool, no trim warnings. |
Documentation
| Getting started | packages, the first tool, commands, binding, DI and configuration in one pass |
| Architecture | the whole pipeline, from Tool.CreateBuilder to result finalization |
| Parameter binding | attributes, naming, ordering, nested option groups, alternate entry points |
| Source generator | what is emitted per command, the command tree, and the generated entry point |
| Dependency injection | how the provider is assembled and how [Inject] is resolved |
| Hosting | IHostBuilder conformance, configuration scopes, ToolHost, standalone commands, ApplyTo |
| Middleware | the chain, ICommandExecutor, error mapping, cancellation |
| Logging | Serilog wiring, verbosity flags, the default console sink, LoggingCommand |
| Object output | descriptors, formatters, the JSON and YAML emitters, trimming |
| NativeAOT | what it costs, what to switch off, and what does not work |
Runnable projects for all of it live under examples/ — a hello-world tool,
the binding showcase, the formatter matrix, an ASP.NET Core subcommand, and a single-file
tool with no project at all.
Building from source
dotnet build src/triaxis.CommandLine.sln
dotnet test src/triaxis.CommandLine.sln
dotnet test src/triaxis.CommandLine.sln -f net48 # needs mono on Linux
dotnet build examples/Examples.sln
License
This package is licensed under the MIT License.
Copyright © 2023 triaxis s.r.o.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- triaxis.CommandLine (>= 2.6.0)
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- triaxis.CommandLine (>= 2.6.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on triaxis.CommandLine.ObjectOutput:
| Package | Downloads |
|---|---|
|
triaxis.CommandLine.Tool
A set of opinionated extensions built on top of System.CommandLine for quick commandline tool project setup |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.6.0 | 235 | 8/9/2026 |
| 2.6.0-rc.1 | 60 | 8/9/2026 |
| 2.6.0-beta.2 | 60 | 8/9/2026 |
| 2.6.0-beta.1 | 57 | 8/9/2026 |
| 2.5.2 | 126 | 8/6/2026 |
| 2.5.1 | 788 | 6/24/2026 |
| 2.5.0 | 370 | 6/15/2026 |
| 2.4.0 | 703 | 5/8/2026 |
| 2.3.0 | 156 | 5/8/2026 |
| 2.2.4 | 146 | 5/1/2026 |
| 2.2.3 | 166 | 4/23/2026 |
| 2.2.2 | 379 | 4/18/2026 |
| 2.2.1 | 144 | 4/18/2026 |
| 2.2.0 | 678 | 4/16/2026 |