mirror of
https://github.com/mikefarah/yq.git
synced 2026-03-10 15:54:26 +00:00
Adds a new CLI flag that enables compact sequence indentation where '- ' is
considered part of the indentation. This leverages the CompactSeqIndent()
method from the underlying go.yaml.in/yaml/v4 library.
Example output with --yaml-compact-seq-indent:
parent:
items:
- one
- two
Instead of the default:
parent:
items:
- one
- two
Closes #1841
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package yqlib
|
|
|
|
type YamlPreferences struct {
|
|
Indent int
|
|
ColorsEnabled bool
|
|
LeadingContentPreProcessing bool
|
|
PrintDocSeparators bool
|
|
UnwrapScalar bool
|
|
EvaluateTogether bool
|
|
FixMergeAnchorToSpec bool
|
|
CompactSequenceIndent bool
|
|
}
|
|
|
|
func NewDefaultYamlPreferences() YamlPreferences {
|
|
return YamlPreferences{
|
|
Indent: 2,
|
|
ColorsEnabled: false,
|
|
LeadingContentPreProcessing: true,
|
|
PrintDocSeparators: true,
|
|
UnwrapScalar: true,
|
|
EvaluateTogether: false,
|
|
FixMergeAnchorToSpec: false,
|
|
CompactSequenceIndent: false,
|
|
}
|
|
}
|
|
|
|
func (p *YamlPreferences) Copy() YamlPreferences {
|
|
return YamlPreferences{
|
|
Indent: p.Indent,
|
|
ColorsEnabled: p.ColorsEnabled,
|
|
LeadingContentPreProcessing: p.LeadingContentPreProcessing,
|
|
PrintDocSeparators: p.PrintDocSeparators,
|
|
UnwrapScalar: p.UnwrapScalar,
|
|
EvaluateTogether: p.EvaluateTogether,
|
|
FixMergeAnchorToSpec: p.FixMergeAnchorToSpec,
|
|
CompactSequenceIndent: p.CompactSequenceIndent,
|
|
}
|
|
}
|
|
|
|
var ConfiguredYamlPreferences = NewDefaultYamlPreferences()
|