dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.43k stars 384 forks source link

[Proposal] Unifying public parts of ArgumentResult and OptionResult to ValueResult and isolating parser support #2356

Open KathleenDollard opened 8 months ago

KathleenDollard commented 8 months ago

It may be valuable to have a single ValueResult. This is a working document to help with that decision.

A benefit is that binding and other calling code, including that directly using the core parser, would not need to worry about two types.

It is also desirable, or perhaps necessary, to separate the public surface from the internal surface of the parser.

Existing differences:

An alternate design:

The internal types would be used during parsing (when the tokens are converted to results) and then the ValueResult instances collected into the public ParseResult.

KalleOlaviNiemitalo commented 8 months ago

I worry about how "isolating parser support" will affect completions, especially when the completion list of an option should depend on arguments of the command. (Imagine supporting completions for msbuild project.csproj -target: where the set of available targets depends on what the project defines.)

KathleenDollard commented 8 months ago

I think that would be as easy. The parser would parse that, and then the values would be available to the completions subsystem.