[Proposal] Unifying public parts of ArgumentResult and OptionResult to ValueResult and isolating parser support
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:
- Option has an
internal`IdentifierToken (passed to constructor) - Option has a public
Implicitproperty and support for it via theCliToken - The symbols are held as
OptionandArgumentsymbols - Option delegates data/value work to it's arguments
- Argument has
OnlyTakeas a public method for custom parsing. It is problematic after parsing.
An alternate design:
-
internal class ParsingOptionResultValueResult- internal values used during parsing
- Determine exactly what
Implicitmeans and who needs it (code differs from what I thought I understood)
-
internal class ParsingArgumentResultValueResult- internal values used during parsing
- If we reinstate custom parsing, find a solution to
OnlyTakethat does not put it on the publicValueResult
-
internal class ParsingCommandResultCommandResult- internal values used during parsing
-
public class ValueResultGetRawValue()GetValueOrDefault<T>()ToString()SymbolParent(this is needed as a symbol can be parented to multiple commands)Location- Errors available, possibly as an extension method
- Results available for other symbols, but possibly just on
ParseResult, not as a method on all results - Unify
GetValueandGetValueOrDefaultor provide names that are more clear, asGetValuealso returns the default value
-
public class CommandResultCommandToString()Parent(this is needed as a symbol can be parented to multiple commands)LocationChildren- Errors available, possibly as an extension method
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.
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.)
I think that would be as easy. The parser would parse that, and then the values would be available to the completions subsystem.