https://github.com/matzefriedrich/command-line-api-extensions
Utilities for System.CommandLine
https://github.com/matzefriedrich/command-line-api-extensions
command-line commandlineparser dotnet-core dotnet-standard system-commandline terminal
Last synced: 3 months ago
JSON representation
Utilities for System.CommandLine
- Host: GitHub
- URL: https://github.com/matzefriedrich/command-line-api-extensions
- Owner: matzefriedrich
- License: mit
- Created: 2020-05-22T09:21:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-24T10:25:23.000Z (over 2 years ago)
- Last Synced: 2023-04-10T04:54:07.828Z (about 2 years ago)
- Topics: command-line, commandlineparser, dotnet-core, dotnet-standard, system-commandline, terminal
- Language: C#
- Homepage:
- Size: 30.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


# System.CommandLine.Extensions
The new `System.CommandLine` API offers for sure more advanced command configuration and execution than the retired `Microsoft.Extensions.CommandLineUtils` API. But the broader set of functionality comes with the burden of more complex boilerplate code required to let the cow fly. The `System.CommandLine.Extensions` API adds a thin application layer to `System.CommandLine` which is similar to the retired API, cuts down functionality and thus brings back the simplicity.
## Greeting Example
````csharp
private static int Main(string[] args)
{
var app = new CommandlineApplication();app.Command("greeting", "Greets the specified person.", greeting =>
{
greeting.Option("--name", "The person´s name.", ArgumentArity.ExactlyOne)
.Option("--polite")
.OnExecute(async (string name, bool polite) =>
{
if (polite) Console.WriteLine($"Good day {name}");
else Console.WriteLine($"Hello {name}");
return await Task.FromResult(0);
});
});return app.Execute(args);
}
````### Usage
````bash
$ demo greeting --name Jon --polite
````