2019-12-03 04:50:32 +00:00
|
|
|
package yqlib
|
|
|
|
|
|
|
|
import (
|
2019-12-16 05:46:20 +00:00
|
|
|
yaml "gopkg.in/yaml.v3"
|
2019-12-03 04:50:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ValueParser interface {
|
2019-12-16 05:46:20 +00:00
|
|
|
Parse(argument string, customTag string) *yaml.Node
|
2019-12-03 04:50:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 05:46:20 +00:00
|
|
|
type valueParser struct {
|
|
|
|
}
|
2019-12-03 04:50:32 +00:00
|
|
|
|
2020-01-08 21:17:56 +00:00
|
|
|
func NewValueParser() ValueParser {
|
|
|
|
return &valueParser{}
|
2019-12-03 04:50:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 05:46:20 +00:00
|
|
|
func (v *valueParser) Parse(argument string, customTag string) *yaml.Node {
|
2020-01-19 21:42:08 +00:00
|
|
|
if argument == "[]" {
|
|
|
|
return &yaml.Node{Tag: "!!seq", Kind: yaml.SequenceNode}
|
2019-12-03 04:50:32 +00:00
|
|
|
}
|
2020-01-19 21:42:08 +00:00
|
|
|
return &yaml.Node{Value: argument, Tag: customTag, Kind: yaml.ScalarNode}
|
2019-12-03 04:50:32 +00:00
|
|
|
}
|