command-line-api
command-line-api copied to clipboard
Fluent API: AddOption should return the Option
Currently we have to write this:
var fileOption = new Option<FileInfo?>(
name: "--file",
description: "The mdp-accelerator file to use.");
rootCommand.AddOption(fileOption);
With a minor change to the API, we could write this instead:
var fileOption = rootCommand.AddOption(new Option<FileInfo?>(
name: "--file",
description: "The mdp-accelerator file to use."));
This would allow us to define, register, and capture the option all in one line instead of having to use two separate statements. And all it would cost is adding return option;
at the end of the AddOption
function.