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

Option to format indices in generated properties #1933

Closed
jakub-bochenski opened this issue Feb 1, 2024 · 2 comments
Closed

Option to format indices in generated properties #1933

jakub-bochenski opened this issue Feb 1, 2024 · 2 comments

Comments

@jakub-bochenski
Copy link

jakub-bochenski commented Feb 1, 2024

Please describe your feature request.
I want the generated properties to work with Spring Boot.

Problem is Spring Boot uses a bracket notation for list indices ([]).

Describe the solution you'd like
If we have data:

# block comments come through
person: # neither do comments on maps
    name: Mike Wazowski # comments on values appear
    pets: 
    - cat # comments on array values appear
    food: [pizza] # comments on arrays do not
emptyArray: []
emptyMap: []

it could output

# block comments come through
# comments on values appear
person.name = Mike Wazowski

# comments on array values appear
person.pets[0]=cat
person.food[1]=pizza

Describe alternatives you've considered
Sed the output

@jakub-bochenski
Copy link
Author

jakub-bochenski commented Feb 2, 2024

FTR sed solution to compact spaces and bracketed indices is:

find \
  -name 'application*.yml' \
  -exec sh -c "yq -o=props {} | sed -r  -e 's/^([^=]+)\.([0-9]+)/\1[\2]/g' -e 's/^([^=]+) = /\1=/g' > \$(echo {} | sed s/.yml$/.properties/)" \; \
  -delete

@mikefarah
Copy link
Owner

Fixed in 4.42.1

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