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

Extract line(s) and column(s) for a path in a file #1109

Closed
mmorel-35 opened this issue Feb 13, 2022 · 1 comment
Closed

Extract line(s) and column(s) for a path in a file #1109

mmorel-35 opened this issue Feb 13, 2022 · 1 comment

Comments

@mmorel-35
Copy link
Contributor

Hi! Is it possible to get the columns and lines for a yml path:
For example

a:
  - b : 'info'
    c : 'other info'

I would like to find something like that

$ yq ast_path 'a[0].c'
{ start_line: 2, end_line: 2, start_column: 2, end_column: 17}
@mmorel-35 mmorel-35 changed the title Extract line(s) and columns for a path in a file Extract line(s) and column(s) for a path in a file Feb 13, 2022
@mikefarah
Copy link
Owner

Released in 4.21.1 (line/column operators)

Note that the underlying parser I'm using only gives the starting positions, not the end - and it's only supported for yaml.

KyleTryon added a commit to CircleCI-Public/cimg-base that referenced this issue Feb 28, 2022
mikefarah/yq#1109
adds the "line" operator used in orb-tools
felicianotech added a commit to CircleCI-Public/cimg-base that referenced this issue Feb 28, 2022
* feat: update YQ to 4.21.1 - minor version change

mikefarah/yq#1109
adds the "line" operator used in orb-tools

* Generate images

Co-authored-by: Ricardo N Feliciano <FelicianoTech@gmail.com>
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