-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow for variable substitution #1
Comments
Hey Antoine, I've been giving this some thought and I'm still playing around with ideas, so no decisions made, but here are some thoughts. Starting at the end; dropping the quotes all together wouldn't work for a variety of reason such as the fact that we want to support every value that's possible in standard JSON, such as I'm not crazy about the single quotes idea because it drives the syntax further away from standard JSON (which will be unintuitive to users of the CLI, IMHO). One idea I'm playing around with (in my head, so far) is passing in variables using a different CLI argument, and doing the substitution ourselves. For example: export VIDEO_MIME="mp4"
jg -e '.video.mimes[*="{}"]' --params "$VIDEO_MIME" This would substitute internally as: jg -e '.video.mimes[*="mp4"]' We could also implement this slightly differently, where you specify the key too: export VIDEO_MIME="mp4"
jg -e '.video.mimes[*="$VIDEO_MIME"]' --params "VIDEO_MIME=$VIDEO_MIME" But this feels far too verbose, so I'd opt for the first implementation. What do you think of that approach? |
Sorry it took a while, but I've now added a release (0.1.7) with the above implementation. If you try using the params flag you can pass in as many parameters as you wish. So for example, this will work:
and will be treated as:
I'll add it to the docs once I've put some usage into it and feel it works as needed. |
Currently (as far as I know), if one wants to use variables substitution in a filter expressions, it becomes a mess of escaped quotes that is diffcult to write and read, like so:
$ jg ".people[{\"craft\":\"$CRAFT\"}]"
Maybe allowing for single quotes in the filter would clean it up a bit:
$ jg ".people[{'craft':'$CRAFT'}]"
Another possibility, but that will only work for keys and value that do not contain
:
or]
, would be to allow dropping the quotes altogether. Though it might be more difficult to implement. Something like:What do you think?
The text was updated successfully, but these errors were encountered: