command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Fluent API: AddOption should return the Option

Open Grauenwolf opened this issue 2 years ago • 0 comments

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.

Grauenwolf avatar Apr 20 '22 03:04 Grauenwolf