Skip to content

-I flag not working as expected #2352

Description

@sedated87

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions