- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 634
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
I wish I could use yq -s with an external file #1194
Labels
Comments
You can do this already, see https://mikefarah.gitbook.io/yq/usage/split-into-multiple-files |
If I try to do that, I get an error. I'm on version 4.24.2.
|
Ah gotcha, an external file 👍🏼 |
mikefarah
added a commit
that referenced
this issue
Apr 29, 2022
Added |
Works great thanks for adding this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wish I could use yq
-s
with an external file.Expressions passed to
-s
can sometimes get quite involved. If I could store them in a file, and refer to them like I do withyq --from-file
, these split expressions can be written in a way that is easier to document and understand.Current
yq
:$: yq --from-file yq.input input.yml -s '(["yml/country", ([$index] | join("") | match("[[:digit:]]+") | ("000" | split("")) *+ (.string | split("")) | [.[-3, -2, -1]] | join("")), (.country | sub("[^[:word:][:space:]]", "") | split(" ") | join("-")), "exports"] | join("-"))'
Desired
yq
:$: yq --from-file yq.input input.yml -S yq.split-files # or... $: yq --from-file yq.input input.yml --split-from-file yq.split-files
Describe alternatives you've considered
Given some Makefile with these dependencies, which are normal files:
I could create an
input.yml
file like this:I might use something like this for my
yq.input
:And for my
yq.split-files
:And see that there are two files created,
yml/country-000-austrailia-exports.yml
andyml/country-001-united-states-exports.yml
.Having all my inputs to
yq
resting on the filesystem allows for me to keep my transformed output up to date with every change to both of these two yq command input "files", which is nice.Additional context
Formats for
style="..."
that can transform number inputs into zero-padded (scientifically notated, integer/float strings, etc.) would make this approach a lot less code to write.The text was updated successfully, but these errors were encountered: