1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Can now update tag/style of nodes without affecting the value

This commit is contained in:
Mike Farah
2020-04-17 17:09:33 +10:00
parent 64135a16e1
commit 23de61a8d7
5 changed files with 64 additions and 10 deletions

View File

@@ -13,10 +13,11 @@ import (
var log = logging.MustGetLogger("yq")
type UpdateCommand struct {
Command string
Path string
Value *yaml.Node
Overwrite bool
Command string
Path string
Value *yaml.Node
Overwrite bool
DontUpdateNodeValue bool
}
func KindString(kind yaml.Kind) string {

View File

@@ -21,7 +21,9 @@ func UpdateNavigationStrategy(updateCommand UpdateCommand, autoCreate bool) Navi
DebugNode(node)
log.Debug("with")
DebugNode(changesToApply)
node.Value = changesToApply.Value
if !updateCommand.DontUpdateNodeValue {
node.Value = changesToApply.Value
}
node.Tag = changesToApply.Tag
node.Kind = changesToApply.Kind
node.Style = changesToApply.Style