You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I'm doing some checks in a pull request and I need to know the line numbers of the current object/array element. I know which lines in the file have changed and I need to compare that list to the lines of an element to see how they should affect the outcome of a check. For instance if I find an error on a line that was not changed in the current pull request, I'd label that issue a warning instead of an error.
For clarity, I'm checking the contents of YAML that I'm not responsible for writing so I have no control over it. I'm just responsible for writing the checks to validate the contents of the files.
Sample YAML:
catpants:
- start: endvalue: stuffother: | Things are here too Look at it go!
- another: onevalue: herelast: sample
Question
I know how to use key | line to obtain the first line of an element, but is there a way to obtain the "length"/end of an element?
So for this example, I can see the first element of catpants spans from lines 2 through 6 counting manually. Is there a programmatic way that yq can determine where it ends? I was thinking of getting the index of the current element (which makes sense for arrays, but not sure how this would work for an object). But I'm also not sure that I can jump into a sequence and then query the current index -- is that possible? I couldn't find anything related in the docs. I'm open to alternative solutions as well.
The text was updated successfully, but these errors were encountered:
Background/Use Case
So I'm doing some checks in a pull request and I need to know the line numbers of the current object/array element. I know which lines in the file have changed and I need to compare that list to the lines of an element to see how they should affect the outcome of a check. For instance if I find an error on a line that was not changed in the current pull request, I'd label that issue a warning instead of an error.
For clarity, I'm checking the contents of YAML that I'm not responsible for writing so I have no control over it. I'm just responsible for writing the checks to validate the contents of the files.
Sample YAML:
Question
I know how to use
key | line
to obtain the first line of an element, but is there a way to obtain the "length"/end of an element?So for this example, I can see the first element of
catpants
spans from lines 2 through 6 counting manually. Is there a programmatic way thatyq
can determine where it ends? I was thinking of getting the index of the current element (which makes sense for arrays, but not sure how this would work for an object). But I'm also not sure that I can jump into a sequence and then query the current index -- is that possible? I couldn't find anything related in the docs. I'm open to alternative solutions as well.The text was updated successfully, but these errors were encountered: