mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
a9c3617b4f
* Decoder Properties * Added properties round trip test * Fixed property decode for github actions * Refactored XML test to use common functions * Switched formatScenario parameter order for more readablity
35 lines
582 B
Go
35 lines
582 B
Go
package yqlib
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
yaml "gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type InputFormat uint
|
|
|
|
const (
|
|
YamlInputFormat = 1 << iota
|
|
XMLInputFormat
|
|
PropertiesInputFormat
|
|
)
|
|
|
|
type Decoder interface {
|
|
Init(reader io.Reader)
|
|
Decode(node *yaml.Node) error
|
|
}
|
|
|
|
func InputFormatFromString(format string) (InputFormat, error) {
|
|
switch format {
|
|
case "yaml", "y":
|
|
return YamlInputFormat, nil
|
|
case "xml", "x":
|
|
return XMLInputFormat, nil
|
|
case "props", "p":
|
|
return PropertiesInputFormat, nil
|
|
default:
|
|
return 0, fmt.Errorf("unknown format '%v' please use [yaml|xml|props]", format)
|
|
}
|
|
}
|