dotnet / dotnet/command-line-api

Fluent interface for System.CommandLine

Open
#540 6 comments 7 reactions 0 assignees View on GitHub
Area-App Models
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Hello everybody,

I have written a fluent interface for the System.CommandLine

Below is the sample from your wiki in fluent form.

```csharp
static Task Main(string[] args)
=> args.ArgsCommandBuilder("My sample app")
.Option("--int-option", 42, "An option whose argument is parsed as an int")
.Option("--bool-option", default, "An option whose argument is parsed as a bool")
.Option("--file-option", default, "An option whose argument is parsed as a FileInfo")
.OnRootCommand((intOption, boolOption, fileOption) =>
{
Console.WriteLine($"The value for --int-option is: {intOption}");
Console.WriteLine($"The value for --bool-option is: {boolOption}");
Console.WriteLine($"The value for --file-option is: {fileOption?.FullName ?? "null"}");
})
.RunAsync();
```
More doc, code, tests and samples can be found on [my github side](https://github.com/EifelMono/EifelMono.ConsoleApp)

I would like to bring this in these project if you think it is useful for others and fits in this project

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.