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

Preserve indent option for write in place #1359

Open
samuelneff opened this issue Sep 22, 2022 · 0 comments
Open

Preserve indent option for write in place #1359

samuelneff opened this issue Sep 22, 2022 · 0 comments

Comments

@samuelneff
Copy link

Please describe your feature request.

We use yq in generic tools to make small changes to yaml files across our enterprise. Most are formatted with 2 character indent but some are 4. It would be nice to be able to detect the current indent level and maintain it instead of having to specify a value or use the default.

Describe the solution you'd like

Given these two yaml files:

countries:
  - Australia
  - USA

and

countries:
    - Australia
    - USA

Running yq with write in place without specifying an indent or with a new flag like --preserve-indent, the two files should both be formatted with the same indentation as they were previously.

Describe alternatives you've considered

Read in the file and detect the current indentation, then pass that to yq with the write command. I'm not sure how to safely and consistently detect current indentation though. I'll ask in discussions separately.

Additional context
none

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

1 participant