Albatross.CommandLine 8.0.1-114.main

Prefix Reserved
This is a prerelease version of Albatross.CommandLine.
This package has a SemVer 2.0.0 package version: 8.0.1-114.main+69e1081.
There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Albatross.CommandLine --version 8.0.1-114.main
                    
NuGet\Install-Package Albatross.CommandLine -Version 8.0.1-114.main
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Albatross.CommandLine" Version="8.0.1-114.main" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Albatross.CommandLine" Version="8.0.1-114.main" />
                    
Directory.Packages.props
<PackageReference Include="Albatross.CommandLine" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Albatross.CommandLine --version 8.0.1-114.main
                    
#r "nuget: Albatross.CommandLine, 8.0.1-114.main"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Albatross.CommandLine@8.0.1-114.main
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Albatross.CommandLine&version=8.0.1-114.main&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Albatross.CommandLine&version=8.0.1-114.main&prerelease
                    
Install as a Cake Tool

Albatross.CommandLine

A .NET library that simplifies creating command-line applications with System.CommandLine. It provides automatic code generation and dependency injection support while maintaining full access to System.CommandLine's capabilities. It is opionionated toward async actions with out of box support for action cancellation and graceful shutdown.

🎉 Now using System.CommandLine v2 stable release for improved reliability and long-term support.

✨ Key Features

  • 🚀 Minimal Boilerplate - Attribute-based command definition with automatic code generation
  • 🔧 Type Safety - Leverages C# nullable reference\value types for automatic requirement detection
  • 📦 Dependency Injection - Built-in DI container integration
  • 🎯 Full Flexibility - Direct access to System.CommandLine when needed
  • 🛠️ Out of Box Support for Cancellation and Graceful Shutdown - Built-in Support for Ctr->C Interruption via Cancellation tokens and Graceful Shutdown
  • 🌟 Minimum Dependencies - Only depends on System.CommandLine and Microsoft.Extensions.Hosting.
  • 🌟 Easy Extensions Use CommandHost.ConfigureHost to bootstrap additional services or use Albatross.CommandLine.Default to include Serilog logging via Albatross.Logging and Json\Environmental Configuration Support via Albatross.Config.

📖 Documentation

📚 Complete Documentation

🔧 Dependencies

  • System.CommandLine 2.0.1+
  • Microsoft.Extensions.Hosting 8.0.1+

🔧 Prerequisites

  • C# Compiler 4.10.0+ (included with .NET 8 SDK)

🚀 Quick Start

1. Install Package

<PackageReference Include="Albatross.CommandLine" Version="8.0.1" />

2. Create Program.cs

internal class Program {
		static async Task<int> Main(string[] args) {
			await using var host = new CommandHost("Sample Command Line Application")
				.RegisterServices(RegisterServices)
				// this method is generated by source generator
				.AddCommands()
				.Parse(args)
				.Build();
			return await host.InvokeAsync();
		}
		static void RegisterServices(ParseResult result, IConfiguration configuration, IServiceCollection services) {
			// RegisterCommands method is generated by codegen
			services.RegisterCommands();
			// register your dependencies here
			services.AddSingleton<IMyService, MyService>();
		}
	}
}

3. Define Your Command

[Verb<HelloCommandHandler>("hello", Description = "Say hello to someone")]
public record class HelloOptions {
    // Required argument (position 0)
    [Argument(Description = "Name to greet")]
    public required string Name { get; init; }
    
    // Optional option
    [Option(Description = "Number of times to greet")]
    public int Count { get; init; } = 1;
}

public class HelloCommandHandler : CommandHandler<HelloOptions> {
    public HelloCommandHandler(HelloOptions options) : base(options) {
    }

    public override async Task<int> Invoke(CancellationToken cancellationToken) {
        for (int i = 0; i < options.Count; i++) {
            await this.Writer.WriteLineAsync($"Hello, {options.Name}!");
        }
        return 0;
    }
}

5. Run It!

dotnet run -- hello "World" --count 3

That's it! The code generator automatically creates the command class and service registrations.

🌟 Advanced Features

Sub-Commands

[Verb<DatabaseBackupAction>("database backup")]
[Verb<DatabaseRestoreAction>("database restore")]
// Creates: database backup, database restore

Shared Options

[Verb<ProjectCommandHandler>("project build", UseBaseParamsClass = typeof(ProjectOptions))]
public record class BuildOptions : ProjectOptions {
    [Option] public string Configuration { get; init; } = "Release";
}

Manual Commands

// Full System.CommandLine control when needed
setup.CommandBuilder.AddWithParentKey("tools", new CustomCommand());

🎯 Global Options

The library creates a single recursive option for logging purposes.

  • -v, --verbosity - Logging level (Error, Warning, Information, Info, Debug, Trace)

🤝 Samples

See the Sample.CommandLine project for comprehensive examples of all features.


📖 Read the Full Documentation →

Product 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Albatross.CommandLine:

Package Downloads
Albatross.CommandLine.Defaults

Package Description

Albatross.CommandLine.Inputs

Package Description

Albatross.EFCore.Admin

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.10 131 3/21/2026
8.0.8 63 2/23/2026
8.0.7 114 1/26/2026
8.0.6 65 1/23/2026
8.0.5 70 1/22/2026
8.0.4 58 1/21/2026
8.0.3 63 1/16/2026
8.0.2 77 1/11/2026
8.0.1 213 1/9/2026
Loading failed