1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

updated cobra package

This commit is contained in:
Mike Farah
2020-12-01 16:16:20 +11:00
parent 8cd290c00b
commit da027f69d7
4 changed files with 184 additions and 7 deletions

View File

@@ -15,9 +15,8 @@ func createEvaluateAllCommand() *cobra.Command {
Aliases: []string{"ea"},
Short: "Loads _all_ yaml documents of _all_ yaml files and runs expression once",
Example: `
yq es '.a.b | length' file1.yml file2.yml
yq es < sample.yaml
yq es -n '{"a": "b"}'
# merges f2.yml into f1.yml (inplace)
yq eval-all --inplace 'select(fileIndex == 0) * select(fileIndex == 1)' f1.yml f2.yml
`,
Long: "Evaluate All:\nUseful when you need to run an expression across several yaml documents or files. Consumes more memory than eval",
RunE: evaluateAll,

View File

@@ -15,9 +15,18 @@ func createEvaluateSequenceCommand() *cobra.Command {
Aliases: []string{"e"},
Short: "Apply expression to each document in each yaml file given in sequence",
Example: `
yq es '.a.b | length' file1.yml file2.yml
yq es < sample.yaml
yq es -n '{"a": "b"}'
# runs the expression against each file, in series
yq e '.a.b | length' f1.yml f2.yml
# prints out the file
yq e sample.yaml
# prints a new yaml document
yq e -n '.a.b.c = "cat"'
# updates file.yaml directly
yq e '.a.b = "cool"' -i file.yaml
`,
Long: "Evaluate Sequence:\nIterate over each yaml document, apply the expression and print the results, in sequence.",
RunE: evaluateSequence,