mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Nicely formats output
This commit is contained in:
parent
5a3c3a7152
commit
eebd319246
10
yaml.go
10
yaml.go
@ -34,7 +34,15 @@ func readProperty(c *cli.Context) {
|
|||||||
var path = c.Args()[1]
|
var path = c.Args()[1]
|
||||||
var paths = strings.Split(path, ".")
|
var paths = strings.Split(path, ".")
|
||||||
|
|
||||||
fmt.Println(readMap(parsedData, paths[0], paths[1:len(paths)]))
|
printYaml(readMap(parsedData, paths[0], paths[1:len(paths)]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func printYaml(context interface{}) {
|
||||||
|
out, err := yaml.Marshal(context)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error printing yaml: %v", err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
func readYaml(c *cli.Context, parsedData *map[interface{}]interface{}) {
|
func readYaml(c *cli.Context, parsedData *map[interface{}]interface{}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user