mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Added more help info about using write with an update script
This commit is contained in:
parent
56c923228d
commit
2ec3b59da2
15
yaml.go
15
yaml.go
@ -33,14 +33,25 @@ yaml r things.yaml a.array[*].blah
|
|||||||
var cmdWrite = &cobra.Command{
|
var cmdWrite = &cobra.Command{
|
||||||
Use: "write [yaml_file] [path] [value]",
|
Use: "write [yaml_file] [path] [value]",
|
||||||
Aliases: []string{"w"},
|
Aliases: []string{"w"},
|
||||||
Short: "yaml w [--inplace/-i] sample.yaml a.b.c newValueForC",
|
Short: "yaml w [--inplace/-i] [--script/-s script_file] sample.yaml a.b.c newValueForC",
|
||||||
Example: `
|
Example: `
|
||||||
yaml write things.yaml a.b.c cat
|
yaml write things.yaml a.b.c cat
|
||||||
yaml write --inplace things.yaml a.b.c cat
|
yaml write --inplace things.yaml a.b.c cat
|
||||||
yaml w -i things.yaml a.b.c cat
|
yaml w -i things.yaml a.b.c cat
|
||||||
|
yaml w --script update_script.yaml things.yaml
|
||||||
|
yaml w -i -s update_script.yaml things.yaml
|
||||||
`,
|
`,
|
||||||
Long: `Updates the yaml file w.r.t the given path and value.
|
Long: `Updates the yaml file w.r.t the given path and value.
|
||||||
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.`,
|
Outputs to STDOUT unless the inplace flag is used, in which case the file is updated instead.
|
||||||
|
|
||||||
|
Update Scripts:
|
||||||
|
Note that you can give an update script to perform more sophisticated updated. Update script
|
||||||
|
format is a yaml map where the key is the path and the value is..well the value. e.g.:
|
||||||
|
---
|
||||||
|
a.b.c: true,
|
||||||
|
a.b.e:
|
||||||
|
- name: bob
|
||||||
|
`,
|
||||||
Run: writeProperty,
|
Run: writeProperty,
|
||||||
}
|
}
|
||||||
cmdWrite.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
cmdWrite.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")
|
||||||
|
Loading…
Reference in New Issue
Block a user