From 2ec3b59da2fdc410225137d4ca6d244ac7bf21dc Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Fri, 9 Oct 2015 21:30:15 +1100 Subject: [PATCH] Added more help info about using write with an update script --- yaml.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/yaml.go b/yaml.go index bf507c71..aa64bb72 100644 --- a/yaml.go +++ b/yaml.go @@ -33,14 +33,25 @@ yaml r things.yaml a.array[*].blah var cmdWrite = &cobra.Command{ Use: "write [yaml_file] [path] [value]", 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: ` yaml write 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 --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. -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, } cmdWrite.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the yaml file inplace")