Skip to content

Commit

Permalink
Add yaml prefs to allow compact sequence indent
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed May 12, 2023
1 parent 8e4847b commit cdbfb91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/yqlib/encoder_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func (ye *yamlEncoder) Encode(writer io.Writer, node *yaml.Node) error {
var encoder = yaml.NewEncoder(destination)

encoder.SetIndent(ye.indent)
if ye.prefs.CompactSequenceIndent {
encoder.CompactSeqIndent()
}

if err := encoder.Encode(node); err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/yqlib/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type YamlPreferences struct {
PrintDocSeparators bool
UnwrapScalar bool
EvaluateTogether bool
CompactSequenceIndent bool
}

func NewDefaultYamlPreferences() YamlPreferences {
Expand All @@ -13,6 +14,7 @@ func NewDefaultYamlPreferences() YamlPreferences {
PrintDocSeparators: true,
UnwrapScalar: true,
EvaluateTogether: false,
CompactSequenceIndent: false,
}
}

Expand Down

0 comments on commit cdbfb91

Please sign in to comment.