Skip to content

-I flag not working as expected #2352

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

Open
sedated87 opened this issue May 1, 2025 · 0 comments
Open

-I flag not working as expected #2352

sedated87 opened this issue May 1, 2025 · 0 comments
Labels

Comments

@sedated87
Copy link

sedated87 commented May 1, 2025

Describe the bug
Trying to get my keys to line up like the following using the -I0 flag

level1:
  level2:
  - item1
  - item2

However I noticed that -I0 adds 4 spaces on each level, -I1 matches what -I2's output is

$ yq --version
yq (https://github.com/mikefarah/yq/) version v4.44.5
Operating system: Ubuntu 22.04.5 LTS x86_64

Input Yaml

level1:
  level2:
    - item1
    - item2

Command

$ yq -I0 test.yaml  # No indentation
yq -I1 test.yaml  # 1 space
yq -I2 test.yaml  # 2 spaces
yq -I3 test.yaml  # 3 spaces

Actual behavior

# should be 0
level1:
    level2:
        - item1
        - item2

# should be 1
level1:
  level2:
    - item1
    - item2

# is the default 2
level1:
  level2:
    - item1
    - item2

# is the specified 3
level1:
   level2:
      - item1
      - item2

Expected behavior

# 0
level1:
  level2:
  - item1
  - item2
# 1
level1:
  level2:
   - item1
   - item2

Side note for what I am trying to do, I am trying to "fix" yaml configurations so it meets my jobs requirements first and then trying to figure out how to only have yq modify the section I am working on instead of modifying the full file with indention changes. Any help would be greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant