dotnet / dotnet/command-line-api
Override binding names
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
Currently we are forced to use the name of an alias of the option/argument we want to bind. Which makes it really awkward in cases like this:
```cs
var rootCommand = new RootCommand
{
new Option("--manifest")
};
rootCommand.Handler = CommandHandler.Create(DownloadAsync);
```
```cs
public class InputModel
{
public ulong[] Manifests { get; init; }
}
```
^ this won't work because binder expects the property to be named `Manifest`
It can be workarounded by setting the option name to `manifests` like so
```cs
new Option("--manifest") { Name = "manifests" }
```
But it adds an unwanted alias and clutters the help command
There are 2 ways to go around this issue (in my opinion both should be implemented):
1. Do it like #1056 suggested by adding a new property to Option/Argument
2. Override the property binding name with an attribute like so https://github.com/js6pak/command-line-api/commit/e3ea5662926b44264ae040573803a0c265c9c069#diff-e27da87190195525fc21293619fbda5866432214bd0f789fd38db8ca20fd3e69R68-R76 (same thing for parameter binding)
Contributor guide
Assessment
This issue has not been assessed yet.