You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Align parser configuration APIs to the ParseResult API surface #251
A common friction point has been the differences between the fluent builder API and the Option, Command, and Argument types that are created by it when Build is called, which can then be accessed from a ParseResult.
In order to make the API more consistent and easier to understand, we should try to achieve the following:
Parser component types (Option, Command, Argument) should be mutable at configuration time and allow developers to set properties, add options to a command, and so on, rather than passing complex structures into constructors as is now required.
These types should be effectively immutable once composed into a Parser in order to keep concurrent use cases robust.
The configuration-time (read/write) API surface should be a superset of the parse-time (read-only) API surface, at least in terms of naming and structure, even if the underlying types are different.
(Also, as part of this, I hope we can also simplify the interface definitions.)
ISymbolSet Symbols { get; } what is symbols field in symbol? itself?
It doesn't include itself. Maybe Children would be clearer?
_3. to config a tree we need to create 2 objects first and then let child to point to parent right? I think It is not very intuitive, but still okish. i get it after looking at the signature for a while
The current proposal is that adding a child symbol will set the parent for you, although it's not ideal. The problem with that is that the following code would compile but the expectation is unclear:
varcommand1=newCommand();varcommand2=newCommand();varoption=newOption();command1.AddOption(option);command2.AddOption(option);// Would this reparent? Remove it from the command1? Throw?
It doesn't include itself. Maybe Children would be clearer?
That would be better. And no setter on mutable object's parent? So the user will know they should only config children
The current proposal is that adding a child symbol will set the parent for you, although it's not ideal. The problem with that is that the following code would compile but the expectation is unclear:
As before, make parent readonly on mutable object should help. Or AddOption method as the example, so there is only one way to do it.
For the example below, maybe consider command1 and command2 has the same option? dotnet run and dotnet build both support --configuration option?
Activity
jonsequitur commentedon Oct 12, 2018
@wli3 Re: #252 (comment)
Good points. This issue will likely stick around longer than any one PR so it's worth moving the discussion here.
"Symbol" is being used in this sense: https://en.wikipedia.org/wiki/Symbol_(programming). We're using it to refer to the configurable elements of a developer's command line app's syntax, i.e.
IOptionandICommandareISymbols. Of course, we could maybe find clearer terminology for all of these. Any ideas?(Also, as part of this, I hope we can also simplify the interface definitions.)
It doesn't include itself. Maybe
Childrenwould be clearer?The current proposal is that adding a child symbol will set the parent for you, although it's not ideal. The problem with that is that the following code would compile but the expectation is unclear:
wli3 commentedon Oct 12, 2018
That would be better. And no setter on mutable object's
parent? So the user will know they should only configchildrenAs before, make
parentreadonly on mutable object should help. Or AddOption method as the example, so there is only one way to do it.For the example below, maybe consider command1 and command2 has the same option?
dotnet runanddotnet buildboth support--configurationoption?