Open
Description
As a new-comer to this library I find the first example in the tutorial a bit confusing. The fact that RootCommand is an enumerable is not immediately obvious, and there are way too many {}
for my taste.
I think it would be nice to use Option<T>
in the tutorial, and writing the output in one line which gets rid of most of the noise:
var command = new RootCommand
{
new Option<string>("--a-string"),
new Option<int>("--an-int"),
};
command.Handler = CommandHandler.Create((string aString, int anInt) =>
Console.WriteLine($"aString: {aString}, anInt: {anInt}"));
await command.InvokeAsync("--a-string \"Hello world!\" --an-int 123");
vs.
var command = new RootCommand
{
new Option("--a-string") { Argument = new Argument<string>() },
new Option("--an-int") { Argument = new Argument<int>() }
};
command.Handler = CommandHandler.Create(
(string aString, int anInt) =>
{
Console.WriteLine($"{aString}");
Console.WriteLine($"{anInt}");
});
await command.InvokeAsync("--an-int 123 --a-string \"Hello world!\" ");