-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move CompletionSourceList
extension methods to CompletionSourceList
#1910
Comments
Currently we have three different ways of adding completions:
but returns a reference to var argument = new Argument<string>()
.AddCompletions(expectedSuggestions);
and also returns the reference to If we wanted to give up on chaining, we could have a single instance method on argument.AddCompletions(x);
option.Argument.AddCompletions(x); but we most likely don't want that. I think that we should just remove @jonsequitur thoughts? |
Since completions can also be cleared, would it be clearer to have all completion-related functionality on a Note that |
I can see that doing this would break some stuff. The following syntax: command-line-api/src/System.CommandLine.Tests/CompletionTests.cs Lines 607 to 610 in b8ddb00
would stop working, as it maps to: Argument<string> argument = new Argument<string>();
argument.Completions.Add((CompletionContext _) => new string[3] { "vegetable", "mineral", "animal" }); to get it working we would need to specify the types in explicit way: new Argument<string>
{
Completions = { _ => new[] { new CompletionItem("vegetable"), new CompletionItem("mineral"), new CompletionItem("animal") } }
} |
It would, but we would lose the fluent API syntax with chaining (assuming we would remove the extension methods and added a new property to Option) |
Fluent APIs aren't the norm in the System namespace anyway (though people do ask for them often.) |
We have removed new Argument<DayOfWeek>
{
Completions = { "mon", "tues", "wed", "thur", "fri", "sat", "sun" }
} But... I am not sure if this feature is discoverable as @jonsequitur @jozkee What do you think about removing these extensions methods and promoting |
That syntax creates a separate one-element array and completion source for each string, bloating the IL somewhat. SharpLab Doubling the braces like I think I'd prefer removing the |
I agree. |
This does not answer my question:
|
Completions and validations are often orthogonal. For example, a completion source might contain a set of legal values from the file system, but these might not be the only acceptable values. |
The text was updated successfully, but these errors were encountered: