Skip to content

Control the way lists/arrays are displayed #1085

Answered by mikefarah
felipesere asked this question in Q&A
Discussion options

You must be logged in to vote

Yep - you can use the style operator.

yq e -i 'with(.pull_requests.select; 
  . style= "" |
  . += {"repo": "felipesere/dotfiles"} |
  . += {"repo": "felipesere/journal"}
)' config.yml
pull_requests:
  enabled: true
  auth:
    personal_access_token: XYZ
  select:
    - repo: felipesere/dotfiles
    - repo: felipesere/journal

For what it's worth - yq defaults to the current style of the nodes - and for empty arrays/objects this is necessarily the JSON style (as there's no way of specifying an empty list in bullet points).

I think I will change this in future versions to assume the default yaml style for empty arrays and objects.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@felipesere
Comment options

Answer selected by felipesere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants