Declarative syntax for System.CommandLine via attributes for easy, fast, strongly-typed (no reflection) usage. Includes a source generator which automagically converts your classes to CLI commands and properties to CLI options or CLI arguments.
1. Intro to DotMake Command-Line
Declarative syntax for System.CommandLine via attributes for easy,
fast, strongly-typed (no reflection) usage. Includes a source generator
which automagically converts your classes to CLI commands and
properties to CLI options or CLI arguments.
About this project
https://dotmake.build
https://github.com/dotmake-build/command-line
https://www.nuget.org/packages/DotMake.CommandLine
2. System.CommandLine is a very good parser but you need a lot of
boilerplate code to get going and the API is hard to discover. This
becomes complicated to newcomers and also you would have a lot of
ugly code in your Program.cs to maintain. What if you had an easy class-
based layer combined with a good parser?
Why Use DotMake Command-Line?
3. Install the library to your console app project with NuGet.
In your project directory, via dotnet cli:
dotnet add package DotMake.CommandLine
or in Visual Studio Package Manager Console:
PM> Install-Package DotMake.CommandLine
Prerequisites
.NET 6.0 and later project or .NET Standard 2.0 and later project (note that .NET Framework 4.7.2+ can reference netstandard2.0 libraries).
Visual Studio 2022 v17.3+ or .NET SDK 6.0.407+ (our incremental source generator requires performance features added first in these
versions).
Usually a console app project but you can also use a class library project which will be consumed later.
Getting started
4. Create a simple class, e.g. RootCliCommand.
Mark the class with DotMakeCliCommand attribute to make it a CLI command.
Mark a property with DotMakeCliOption attribute to make it a CLI option.
Mark a property with DotMakeCliArgument attribute to make it a CLI argument.
Add a method with name Run or RunAsync to make it the handler for the CLI
command. Call DotMakeCli.Run<RootCliCommand> or
DotMakeCli.RunAsync<RootCliCommand> method with your class name to run
your CLI app.
Usage
5. More questions about DotMake Command-Line ?
Links:
https://twitter.com/DotMakeBuild
https://www.youtube.com/@DotMake-Build
https://dotmake.build
https://github.com/dotmake-build/command-line
https://www.nuget.org/packages/DotMake.CommandLine