Open gnfzdz opened 1 year ago
@gnfzdz, the condition/if/then/else constructs are extremely readable, and having Python-based condition providers is the correct -- and portable -- way to address this. I run dotbot across multiple operating systems and shell environments; shelling out to an unknown shell to run a string blindly simply doesn't work.
I'm 100% on board for this.
There's actually two requests here, but given the overlap I thought it suitable to just raise a single issue:
Motivation
There are currently 3 plugins linked from the official documentation that provide a condition and a container of tasks to be executed based on the outcome (if, ifarch, ifplatform). Dotbot users have already adopted this type of plugin so the interest is clearly there.
The most flexible (and similar to this request) is the if plugin which takes a single shell command. Personally, there are at least a couple other conditions that I'd like to share with the community that aren't well suited to a shell one-liner.
Notably, all three of the plugins also share the same issue. They don't propagate defaults from the parent context (and scope any new defaults set to the child context).
I think it would be great to provide improved support for this pattern in the core dotbot project itself.
Examples
First, you can see below a couple options for a hypothetical new directive. I don't actually have a strong preference here. Whatever we think is least likely to conflict with a custom plugin name.
Next you can see a few variants of the condition. I actually think it makes sense to support all of these.
I'm envisioning the condition plugins following the same pattern as those providing directives. A new test runner class would take the full condition and delegate to the appropriate condition plugins for evaluation.
Other thoughts