Albatross.CommandLine.Outputs
9.0.0-rc.294
Prefix Reserved
dotnet add package Albatross.CommandLine.Outputs --version 9.0.0-rc.294
NuGet\Install-Package Albatross.CommandLine.Outputs -Version 9.0.0-rc.294
<PackageReference Include="Albatross.CommandLine.Outputs" Version="9.0.0-rc.294" />
<PackageVersion Include="Albatross.CommandLine.Outputs" Version="9.0.0-rc.294" />
<PackageReference Include="Albatross.CommandLine.Outputs" />
paket add Albatross.CommandLine.Outputs --version 9.0.0-rc.294
#r "nuget: Albatross.CommandLine.Outputs, 9.0.0-rc.294"
#:package Albatross.CommandLine.Outputs@9.0.0-rc.294
#addin nuget:?package=Albatross.CommandLine.Outputs&version=9.0.0-rc.294&prerelease
#tool nuget:?package=Albatross.CommandLine.Outputs&version=9.0.0-rc.294&prerelease
Albatross.CommandLine.Outputs
Renders CLI command results as stable JSON so a command's output is a reliable contract for humans, shell scripts, and AI/automation alike. Built for Albatross.CommandLine on System.Text.Json, it keeps standard output clean: a single predictable result shape, and terminal color that is stripped automatically when the output is piped.
Key Features
- Standard result envelope -
CommandOutputandCommandOutput<T>give every command one predictable shape for both success and failure: command key, message, errors, exit code, optional log folder, and typedData. - Stable schema over compactness - The shared
System.Text.Jsonoptions drop nulls but keep default values and empty collections, so a consumer never has to disambiguate "empty" from "absent" — collections are always arrays, and no field has to be inferred from a missing key. - Pipe- and AI-safe rendering - Objects and arrays print indented and syntax-highlighted on a terminal; ANSI color is stripped automatically when redirected or piped, and scalar results print raw so scripts can capture them directly.
- Compact mode - The
--compactoption emits minified single-line JSON with no indentation or color, ready to pipe intojqor any other JSON tool. - Interruptible printing -
PrintAsyncwrites in slices and checks the cancellation token between them, so Ctrl+C stops a large print promptly; its output is uncolored and always valid JSON, even when indented and redirected.
Quick Start
Add the compact option to a command's parameters, then write the result through the Print extension:
using Albatross.CommandLine;
using Albatross.CommandLine.Annotations;
using Albatross.CommandLine.Outputs;
[Verb<GetWidgetsHandler>("get widgets")]
public record class GetWidgetsParams {
[UseOption<CompactOption>]
public bool Compact { get; init; }
}
public class GetWidgetsHandler : IAsyncCommandHandler {
readonly GetWidgetsParams parameters;
readonly IWidgetService service;
public GetWidgetsHandler(GetWidgetsParams parameters, IWidgetService service) {
this.parameters = parameters;
this.service = service;
}
public async Task<int> InvokeAsync(CancellationToken cancellationToken) {
var widgets = await service.GetAll(cancellationToken);
widgets.Print(parameters.Compact);
return 0;
}
}
myapp get widgets # indented, colored JSON array
myapp get widgets --compact # single-line JSON
myapp get widgets --compact | jq -r '.[].name' # shape the output with an external tool
For large results, or output a program will parse, use await widgets.PrintAsync(parameters.Compact, cancellationToken): it can be interrupted with Ctrl+C, at the cost of color.
Results are serialized with System.Text.Json through the read-only Extensions.CompactSerializerOptions and Extensions.FormattedSerializerOptions, so customize your own types with System.Text.Json.Serialization attributes such as [JsonPropertyName] and [JsonIgnore].
For commands that report their own outcome instead of returning data, use ParseResult.PrintSuccess(...) and ParseResult.PrintError(...), which emit a CommandOutput envelope to stdout and stderr respectively.
Dependencies
- Albatross.CommandLine 9.0.0
- System.CommandLine 3.0.0-rc.3.26522.148 (prerelease)
- Spectre.Console 0.57.2
- Spectre.Console.Json 0.57.2
Prerequisites
- .NET 10.0 or later.
Documentation
Links
- Outputs Library — the envelope,
Printbehavior, error reporting, serialization rules, and shaping output withjq. - Reusable Parameters — applying
CompactOptionto a command with[UseOption<T>].
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Albatross.CommandLine (>= 9.0.0-rc.294)
- Spectre.Console (>= 0.57.2)
- Spectre.Console.Json (>= 0.57.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Albatross.CommandLine.Outputs:
| Package | Downloads |
|---|---|
|
Albatross.EFCore.Admin
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0-rc.294 | 58 | 11/16/2026 |
| 9.0.0-rc.288 | 126 | 10/14/2026 |
| 9.0.0-rc.284 | 174 | 7/24/2026 |
| 9.0.0-rc.281 | 90 | 7/17/2026 |
| 9.0.0-rc.270 | 134 | 7/13/2026 |