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 an If command #6

Open
RomainGehrig opened this issue Oct 4, 2022 · 0 comments
Open

Add an If command #6

RomainGehrig opened this issue Oct 4, 2022 · 0 comments
Labels
design This needs some thinking enhancement New feature or request

Comments

@RomainGehrig
Copy link
Member

If(a, b, c)

  • First argument is a Python method that evaluates to True/False (by Python truthiness rules)
  • Second argument is a command for the true branch
  • Third argument is a command for the else branch, if given.

Design question: when should the first argument be evaluated ?

  • At compose time: we only have access to config and args. Theoretically, only the arguments of the taken branch would be needed but the branch may change between invocations. Argparser would then complain of missing or unrecognized parameters.
  • At run time: we have access to config, args and previous command output but we don't know which branch would be taken so we need arguments for both.

Alternative: StdinConverter can be (partially) used to replace the executed command at run time. Eg. StdinConverter(Cmd(sub=BranchA()), converter=lambda s: {} if not predicate(s) else {'sub': BranchB()}). However, it would not expose the arguments of BranchB and Cmd is a command that takes a subcommand as its argument.

@RomainGehrig RomainGehrig added enhancement New feature or request design This needs some thinking labels Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design This needs some thinking enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant