Skip to content

substrant/dotnet-command-line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Substrant.CommandLine

Attribute-driven, AOT-compatible command-line parsing for .NET, maintained by Substrant Softworks LLC.

Overview

Substrant.CommandLine is a lightweight command line parser used internally by us that follows a declarative framework similar (but not exact) to CommandLineParser.

We use a combination of attributes, assembly information, and C# source generation to provide a fast, strongly-typed, declarative way to define CLI commands and options.

This project builds on top of Microsoft's System.CommandLine, a dynamic, AOT-compatible, and battle-tested command line parser for .NET.

Benefits

This library is super cool because:

  • It is purely declarative without the reflection bloat.
  • This library reduces boilerplate in both System.CommandLine and CommandLineParser.
  • We used a solid base framework that is actively maintained for parsing.

We're releasing this as open-source software because:

  • This library has many use-cases outside of our internal tooling.
  • We believe that open-source software can be a learning experience for many.

Usage

If you're familiar with System.CommandLine and source generation, this should be relatively straightforward to use. If not, we recommend checking out the documentation for those technologies first.

To use this library, simply add the Substrant.CommandLine and Substrant.CommandLine.Generator to your project and start defining your verbs, options, and assembly information. The source generator will expose a Cli class with a Parse method that you can call to parse the command line arguments. It returns a ParseResult from System.CommandLine. See the examples at Substrant.CommandLine.Tests for more details.

Expectations

This project is primarily maintained to meet our needs, but we will accept improvements if they are backwards-compatible with the current source. The project is licensed under the Apache 2.0 license. Use this library within the guidelines of the license, that's all we ask.

About

Attribute-driven, AOT-compatible command-line parsing for .NET.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages