-
-
Notifications
You must be signed in to change notification settings - Fork 628
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 support for Conditionals and Comparisons 'if-then-else' #95
Comments
Has it been implemented? |
No:
@mikefarah I think you closed this by accident. |
really odd that we don't have conditionals, i see all related issues are closed without any comments @mikefarah can you please comment on these? is it going to be implemented, if not can we get any rationale? |
Oops - sorry I closed a bunch of issues back then that didn't seem to have anyone interested in them (then didn't see the comments). Re opening. |
There is a work around detailed here in the docs: https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#logic-without-if-elif-else |
How can I use it as an expression in a .map? |
It sure would be nice to have more than one demo. Maybe something more complex perhaps. |
The workaround does leave a lot to be desired. For example, I have been unable to figure out how to adapt that example to changing a single YAML string based on the value of an environment variable. Or any other (seemingly simpler) conditional related to a single string. Or to straight-up As far as I can tell, the second you I've tried using |
Probably the biggest thing not clearly documented is, what happens with
This prints "hello". But why if |
Looks like the result of the This workaround references the context $ myvar=fred yq -n '(select(strenv(myvar) == "fred") | . = "is-fred") // "is-not-fred"'
is-fred
$ myvar=foo yq -n '(select(strenv(myvar) == "fred") | . = "is-fred") // "is-not-fred"'
is-not-fred |
Add support for Conditionals and Comparisons 'if-then-else'
The text was updated successfully, but these errors were encountered: