Skip to content
drmathiasPublic

About

Source-generated AoT-friendly CLI framework for .NET

Topics

Resources

Stars

16 stars

Watchers

0 watching

Forks

Repository files navigation

AnyCli

License: MIT .NET 10 .NET 11 AOT Ready GitHub Stars

AnyCli is a source-generated, AOT-friendly command-line framework for .NET with typed command parameters.

Read the documentation for getting started, guides, and the API reference.

Philosophy

AnyCli is optimised for both utility and extensibility. It is mildly opinionated and suitable for building almost all types of CLI apps. If your use case isn't supported, please open an issue.

Packages

Package NuGet Details
AnyCli NuGet Downloads Core framework for building CLI applications.
AnyCli.SpectreConsole NuGet Downloads Styled output, tables, markup, and rich rendering capabilities.

Features

  • AOT-compatible command registration and execution
  • Source-generated parameter binding with no runtime reflection
  • Typed positional arguments and named options
  • Required, optional, variadic, collection, and defaulted parameters
  • Nested command groups and executable commands with subcommands
  • Custom value parsers
  • Custom default value providers
  • Dependency injection support
  • Typed enum exit codes
  • Typed global options
  • Interceptor middleware
  • Full async and cancellation support for commands, parsers, default value providers and interceptors
  • Fully customisable help and error handling
  • Built in internationalisation - localized error messages and help for English, French, German, Spanish, Brazilian Portuguese, Italian, and Dutch
  • Configurable localization
  • Optional Spectre.Console adapter for rich, styled terminal output and error messages (tables, markup, progress bars etc.)

Installation

dotnet add package AnyCli

For Spectre.Console integration:

dotnet add package AnyCli.SpectreConsole

Benchmarks

Environment: macOS Tahoe 26.2, Intel Core i7-9750H, 12 logical cores, .NET SDK 11.0.100, .NET 11.0.0, X64.

Invocation

Rank Framework Mean Median Ratio Allocated
1 ConsoleAppFramework 5.797 ns 5.797 ns 0.006 0 B
2 AnyCli 911.346 ns 910.387 ns 1.000 1360 B
3 XenoAtom.CommandLine 2,078.393 ns 2,080.561 ns 2.281 2992 B
4 System.CommandLine 3,481.193 ns 3,481.707 ns 3.820 4848 B
5 CliFx 3,738.186 ns 3,737.239 ns 4.102 4392 B
6 Spectre.Console.Cli 102,894.152 ns 102,856.805 ns 112.905 45646 B

Cold start (JIT)

Rank Framework Mean Median Ratio
1 ConsoleAppFramework 57.88 ms 57.82 ms 0.52
2 XenoAtom.CommandLine 91.62 ms 91.70 ms 0.82
3 CliFx 103.14 ms 102.99 ms 0.93
4 AnyCli 111.41 ms 109.32 ms 1.00
4 System.CommandLine 123.47 ms 112.96 ms 1.11
5 Spectre.Console.Cli 212.38 ms 211.22 ms 1.91

Cold start (NativeAOT)

Rank Framework Mean Median Ratio
1 XenoAtom.CommandLine 10.03 ms 10.03 ms 0.86
2 ConsoleAppFramework 10.87 ms 10.74 ms 0.93
2 AnyCli 11.74 ms 11.67 ms 1.00
2 CliFx 12.28 ms 12.09 ms 1.05
2 System.CommandLine 13.28 ms 13.36 ms 1.13

Ranks are BenchmarkDotNet statistical ranks; ties indicate statistically similar results.

Kudos

Inspiration for the framework primarily comes from both ConsoleAppFramework and Spectre.Console.Cli.

License

MIT

About

Source-generated AoT-friendly CLI framework for .NET

Topics

Resources

Stars

16 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages