Closed
Description
Based on various recent discussions with @jozkee and @KalleOlaviNiemitalo
#1953 (comment)
https://github.com/dotnet/command-line-api/pull/1959/files#r1025309941
I've realized that:
- we currently don't expose a possibility to remove
Completions
fromOption<T>
(Argument exposes.Completions
property, but Option does not). Most of the methods exposed by Option simply delegate to.Argument
which is an internal property. - there is more than one way of adding new completions and validators:
symbol.AddValidator
andsymbol.Validators.Add
The questions I have:
- should we simplify the public API surface by just exposing the mutable collections and removing
Add*
methods? @bartonjs what is the recommended approach for such scenarios? The change I am talking about:
public class Argument<T>
{
public ICollection<Func<CompletionContext, IEnumerable<CompletionItem>>> Completions { get; }
- public Argument<T> AddCompletions(Func<CompletionContext, IEnumerable<CompletionItem>> completionsDelegate)
// we don't expose ClearCompletions()
}
- should we remove the
Option
methods that just delegate toArgument
and exposeOption.Argument
? @jonsequitur this has most likely been discussed in the past, what is the main reason for not exposing this property?
public class Option<T>
{
+ public Argument<T> { get; }
- public void SetDefaultValue(T value);
- public void SetDefaultValueFactory(Func<T> defaultValueFactory)
- public Option<T> AcceptOnlyFromAmong(params string[] values)
- public Option<T> AddCompletions(params string[] completions)
- public Option<T> AddCompletions(Func<CompletionContext, IEnumerable<string>> completionsDelegate)
- public Option<T> AddCompletions(Func<CompletionContext, IEnumerable<CompletionItem>> completionsDelegate)
- public Option<T> AcceptLegalFilePathsOnly()
- public Option<T> AcceptLegalFileNamesOnly()
}
It would simplify the public API surface and we would avoid the issues where not every method exposed by Argument
is exposed by Option
, but at a cost of losing the fluent API builder capabilities.
Metadata
Metadata
Assignees
Labels
No labels