Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pipeMode Parameter to EvalCommand #336

Open
rannn505 opened this issue Jan 2, 2024 · 3 comments
Open

Add pipeMode Parameter to EvalCommand #336

rannn505 opened this issue Jan 2, 2024 · 3 comments
Labels
feat New feature or request

Comments

@rannn505
Copy link
Contributor

rannn505 commented Jan 2, 2024

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 the eval command is only passed forward to the next command in the pipeline, for template evaluation etc, but not included in the export result.
  • include/merge: The output is included in the export 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

@rannn505 rannn505 added the feat New feature or request label Jan 2, 2024
@RonConfigu RonConfigu self-assigned this Jan 18, 2024
@RonConfigu
Copy link
Contributor

RonConfigu commented Jan 18, 2024

Development Plan

  • Create type EvalCommandPipeMode = 'include' | 'forward' - Naming TBD @rannn505
  • Add pipeMode?: EvalCommandPipeMode to EvalCommandParameters
  • Add pipeMode to EvalCommandReturn[KEY]['context'] so that the next EvalCommand 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

  1. 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'
  1. 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 RonConfigu linked a pull request Jan 18, 2024 that will close this issue
1 task
@rannn505
Copy link
Contributor Author

@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.

@rannn505
Copy link
Contributor Author

@configu/dev decided to reproductize this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants