Add `pipeMode` Parameter to `EvalCommand`
rannn505 opened this issue · comments
Suggestion
Introducing a pipeMode
parameter to the EvalCommand
. This parameter will control how the output of one eval
command is used when piped into another command. The pipeMode
parameter will accept two values:
forward
: The output of theeval
command is only passed forward to the next command in the pipeline, for template evaluation etc, but not included in theexport
result.include/merge
: The output is included in theexport
result. default mode.override
: TBD @rannn505
This addition would look like this in practice:
# Forward the output to the next command without including in the final result
configu eval --schema './schema1.cfgu.json' --pipe-mode 'forward' | configu eval --schema './schema2.cfgu.json' | configu export ..
# Include the output in the final result
configu eval --schema './schema1.cfgu.json' --pipe-mode 'include' | configu eval --schema './schema2.cfgu.json' | configu export ..
Motivation
The pipeMode
parameter enhances the flexibility of the EvalCommand
, allowing users to precisely control how outputs are handled in piped sequences. This is particularly useful in complex configuration environments where different eval
commands need to be chained together, yet the inclusion of each command's output in the final result needs to be selectively determined. By introducing pipeMode
, we cater to a wider range of user requirements and make the CLI more versatile for various deployment and configuration scenarios.
Context
- https://en.wikipedia.org/wiki/Pipeline_(computing)
- TBD: naming here is not final
Development Plan
- Create type
EvalCommandPipeMode = 'include' | 'forward'
- Naming TBD @rannn505 - Add
pipeMode?: EvalCommandPipeMode
toEvalCommandParameters
- Add
pipeMode
toEvalCommandReturn[KEY]['context']
so that the nextEvalCommand
could identify which to remove - Modify
EvalCommand.run()
to add the new context.pipeMode to its configs. currently on the ones from the schema. Q.1 answer may change it to override piped configs context.pipeMode - Create Test Units
- Update docs (if necessary)
Questions
- Should a command with --pipe-mode 'forward' mark all previous result as
forward
or explicitly the key in this command?
Expected result includes keys from schema1 and schema3 or just schema3?
configu eval --schema './schema1.cfgu.json' | configu eval --schema './schema2.cfgu.json' --pipe-mode 'forward' | configu eval --schema './schema3.cfgu.json'
- Should I implement in Python? @RichardAkman
Unit Tests
Valid Tests
- run EvalCommand and pipe to another, all keys should exists in export
- run EvalCommand(pipeMode='forward') and pipe to another, only keys from the second should exists in export
- run EvalCommand(pipeMode='forward') and pipe to another, and another only keys from the second should exists in export
Notes / Comments / Additional
@RonConfigu, I guess you forgot to tag me on the questions part, but to address your query: No, each EvalCommand
operates independently, and its parameters apply solely to itself. There's no crossover or shared parameters between different EvalCommand
instances.
@configu/dev decided to reproductize this feature.