Commands: Support tasks as parameters and make overriding usable #1825
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is currently not possible to depend-on/call commands with parameters, when the parameter value comes from another task.
The typical workaround is to replace the parameter
T
by aTask[T]
, but this still required to write an additional method and delegate to it from the command. This PR allows to directly useTask[T]
for any supportedT
, so that no additional boilerplate code is necessary.Example:
Fix #766
We also fix another issue we currently face when users tried to override commands. This never really worked out of the box, as the parameters where not statically known. With the new ability to use tasks, we can finally override command and are still be able to call
super.command
to reuse the overridden command result.Here is an example:
I think this is so useful that we should make it a best practice for commands. We even should review existing commands and refactor them in the next major release cycle (0.11).