use Validator to set Handler for VersionOption#2042
use Validator to set Handler for VersionOption#2042adamsitnik wants to merge 1 commit intodotnet:mainfrom
Conversation
|
That's going to blow up if an interactive application has a static Command tree and uses that to parse multiple argument lists and invoke the commands. One of the argument lists includes Even worse if it's a service that parses argument lists and invokes commands in parallel threads. |
|
I agree with @KalleOlaviNiemitalo. As a principle, we should avoid validators (or anything that happens during parsing) creating side effects. Another consideration to keep in mind is that analysis of the parser configuration, without parsing things, should be able to provide information such as which options are "active" / invokable. |
What concept is that? |
An option which performs an action when it's provided by the user. Examples: |
@jonsequitur while reviewing #1969 I reminded myself about the concept of
ActiveOptionand got to conclusion that it can be implemented by using existing public APIs.During validaiton of an OptionResult we know that it's Parent must be CommandResult. CommandResult exposes Command, which exposes Handler. So we can set it during validation.
In case of VersionOption we can validate that there are no errors and then just set the handler.
I am not sure whether Validators should have side effects like this, I just want to hear your thoughts on this.