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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding inline comments to filters for readability #1919

Closed
9numbernine9 opened this issue Jan 15, 2024 · 2 comments
Closed

Adding inline comments to filters for readability #1919

9numbernine9 opened this issue Jan 15, 2024 · 2 comments

Comments

@9numbernine9
Copy link

Please describe your feature request.
Greetings! 馃憢

Would it be possible to add support for comments inside of filters, i.e. a way to document more complex filters? I'm writing a fairly complicated filter for use inside of a bash script and I would like to write some documentation inside of the filter for each step of the filter so that the future maintainer (i.e. probably me) will understand what's going on. 馃槄

Describe the solution you'd like

I'd like it to be possible to define a filter across multiple lines, and have lines that start with # be considered as comments and ignored until the end of the line.

In bash I'm imaging that it could be used something like this - first defining the filter:

filter=$(cat <<'EOF'
# Pretend that this is a comment for a very complex filter
.
EOF
)

And then could be invoked thusly:

yq "$filter" file.yaml

Currently, however, this just prints an error: Error: 1:1: invalid input text "# Comment here..."

Describe alternatives you've considered
N/A

Additional context
This is supported nicely in jq and it would be nice to have this feature here too!

@mikefarah
Copy link
Owner

I like it...just need to do it :)

@mikefarah
Copy link
Owner

Fixed in 4.41.1

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

No branches or pull requests

2 participants