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

ENH: support elif: with selectors #1154

Open
h-vetinari opened this issue Nov 2, 2024 · 3 comments
Open

ENH: support elif: with selectors #1154

h-vetinari opened this issue Nov 2, 2024 · 3 comments

Comments

@h-vetinari
Copy link

Sometimes we need to distinguish things in more than two ways, the most common case being linux-osx-win. It should be possible to write

        files:
          - if: linux
            then:
              - something_linux
            elif: osx               # <--
            then:
              - something_osx
            else:
              - something_win

rather than having to slice things into repeated if-conditions.

@wolfv
Copy link
Member

wolfv commented Nov 2, 2024

Same problem as with match that you could only have a single "elif" as duplicate keys are forbidden. I would also like to see a real life use case because i didn't really have a need when writing recipes.

@h-vetinari
Copy link
Author

you could only have a single "elif" as duplicate keys are forbidden.

Ugh, right. Even a single elif would be better than none though (IMO)

I would also like to see a real life use case because i didn't really have a need when writing recipes.

Happens all the time to me that I need to distinguish 3 or 4 out of (linux,osx,unix,win). Of course it's possible to work around this by opening a new - if:, but that's extra cognitive overhead - correctly parsing multiple if-statements to check which ones do or don't apply is easy to get wrong (which was the main issue I wanted to solve with #1155)

@wolfv
Copy link
Member

wolfv commented Nov 2, 2024

I think we need to come up with something better than a single elif :)

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

No branches or pull requests

2 participants