xc
xc copied to clipboard
Required tasks should inherit inputs (Or be able to map inputs for task X to inputs for required task Y)
Given:
- a task
X
with zero or more inputs - a task
Y
with one or more inputs - a
requires
relationship fromX
toY
When: - i execute task
X
with inputs needed for taskY
Then: - The execution of task
Y
should have access to inputs provided when running taskX
For example, given a readme:
Tasks
y
Inputs: v
echo my inputs are $v
x
Requires: y
echo 'hello world'
this invocation will work:
v=hello xc x
but this one will fail:
xc x hello
Likewise, this readme will also fail in the same way as described above:
Tasks
y
Inputs: v
echo my inputs are $v
x
Inputs: v Requires: y
echo "$v world"
I can see the issue you are raising here. Let's workshop some potential solutions.
I think each task should expresss it's own inputs, so the first example you provided I believe should fail as task y
expresses no required inputs.
You should be able to create Requires statements that contain inputs:
Requires: y hello
But this doesn't help if you would like to have the input to y be dynamic.
Maybe if an input is named the same as an input on a required task, it should be mapped?
What about if requires inputs are expanded:
## y
Inputs: v
```
echo $v
```
## x
Inputs: v
Requires: y $v
I think the second idea is better, because it is more explicit and seems easier to understand. I'd thought the first idea would probably be easier to implement, and possibly simpler to use.
I was looking at the issues here, having a similar use-case, where I would like to change the behavior of a dependency/requirement depending on which task it triggers.
The second solution could work, but I was more thinking of inheriting environment variables of parent tasks, but since this could break existing setups, maybe introduce the concept of "global" environment variables, which could both be set directly under the ## Tasks
, and overridden per task for itself and the required tasks/dependencies it would trigger.