dotnet / dotnet/command-line-api

Fluent API: AddOption should return the Option

Open
#1,715 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Currently we have to write this:

```
var fileOption = new Option(
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(
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.

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.