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

replaceability of pip yq? #193

Closed
clux opened this issue Nov 14, 2018 · 9 comments
Closed

replaceability of pip yq? #193

clux opened this issue Nov 14, 2018 · 9 comments

Comments

@clux
Copy link

clux commented Nov 14, 2018

We use a lot of the pip version of yq because it actually feels like just jq for yaml (same handling of flags etc). However, there's a lot of confusion because the default version on brew is this, but on linux it's the python one, and there are incompatibilities. Here's the first one we hit:

  • python-yq supports -r for reading raw value
  • jq supports -r for reading raw value
  • this project needs r as a subcommand

Any thoughts on possibly consolidating the CLI api for these things?

Edit: I know this is a big ask and probably should just be insta-closed. I was just wondering what you guys thought on this issue.

EDIT: 2023 if this matters to you, check out https://github.com/clux/whyq

@mikefarah
Copy link
Owner

I like the idea of that, having the same CLI api - hadn't actually thought of it.

At the moment I'm using the cobra go lang package to handle arguments, which is where is gets that subcommand syntax. Mind you I think that's actually more typical of cli apps to have '-' arguments as flags to a command/subcommand rather than subcommands - but anyway as you say that how both jq and the other yq work.

Have to give this some thought.

@gsemet
Copy link

gsemet commented Nov 15, 2018

I prefere this yq interface, but it lacks YAML anchor support :( It is possible for both project to work on redefining the name so there is no conflict (I install this yq in /usr/local/bin/yyq)?

@voiski
Copy link

voiski commented Apr 16, 2019

So, can we just bring the same solution of the mentioned kislyuk/yq version? He just wraps jq inside it, so it is why it has all the jq flags. You can use the jq filter feature for now and try to port later.

@voiski
Copy link

voiski commented Apr 16, 2019

For anyone that reaches this card, here is a workaround:

yq r -j file.yq | jq $filter_command | yq -

@mikefarah
Copy link
Owner

The (albeit moonshot) point of yq is to have it dependency free - so I don't want to wrap jq (there are other utilities that do this already.

That said, if you already have jq (or don't mind installing it) piping totally works

@voiski
Copy link

voiski commented Jul 23, 2019

I saw this similar discussion in jq issues and they have some other solutions. One is quite interesting and owe attention.
jqlang/jq#467 (comment)

EDIT:

Sorry, I got it wrong thinking it made jq portable together with the wrapper =(

@voiski
Copy link

voiski commented Jul 23, 2019

So, checking the latest it has standalone binaries that will make your life easier. Forget pip.
https://github.com/stedolan/jq/releases

wget -O jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x jq
yq r -j file.yq | jq $filter_command | yq -

@Blacksmoke16
Copy link

Blacksmoke16 commented Aug 8, 2019

I saw this similar discussion in jq issues and they have some other solutions. One is quite interesting and owe attention.
stedolan/jq#467 (comment)

EDIT:

Sorry, I got it wrong thinking it made jq portable together with the wrapper =(

The binary itself requires jq to work. However if you install it via snap then jq gets installed as well since I made it a dependency.

Also will install jq if you install via brew.


brew install oq

@mikefarah
Copy link
Owner

Latest v4 version now supports jq like syntax (though not everything jq can do yet)

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

5 participants