mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Updated to use -o for output format
This commit is contained in:
parent
043e9128d7
commit
10d4eb3381
63
acceptance_tests/output-format.sh
Executable file
63
acceptance_tests/output-format.sh
Executable file
@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
testOutputJsonDeprecated() {
|
||||||
|
cat >test.yml <<EOL
|
||||||
|
a: {b: ["cat"]}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
read -r -d '' expected << EOM
|
||||||
|
{
|
||||||
|
"a": {
|
||||||
|
"b": [
|
||||||
|
"cat"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOM
|
||||||
|
|
||||||
|
X=$(./yq e -j test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
|
||||||
|
X=$(./yq ea -j test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
}
|
||||||
|
|
||||||
|
testOutputJson() {
|
||||||
|
cat >test.yml <<EOL
|
||||||
|
a: {b: ["cat"]}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
read -r -d '' expected << EOM
|
||||||
|
{
|
||||||
|
"a": {
|
||||||
|
"b": [
|
||||||
|
"cat"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOM
|
||||||
|
|
||||||
|
X=$(./yq e -o=json test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
|
||||||
|
X=$(./yq ea -o=json test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
}
|
||||||
|
|
||||||
|
testOutputProperties() {
|
||||||
|
cat >test.yml <<EOL
|
||||||
|
a: {b: {c: ["cat"]}}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
read -r -d '' expected << EOM
|
||||||
|
a.b.c.0 = cat
|
||||||
|
EOM
|
||||||
|
|
||||||
|
X=$(./yq e -o=props test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
|
||||||
|
X=$(./yq ea -o=props test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
}
|
||||||
|
|
||||||
|
source ./scripts/shunit2
|
@ -43,12 +43,12 @@ See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.`,
|
|||||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "(deprecated) output as json. Set indent to 0 to print json in one line.")
|
rootCmd.PersistentFlags().BoolVarP(&outputToJSON, "tojson", "j", false, "(deprecated) output as json. Set indent to 0 to print json in one line.")
|
||||||
err := rootCmd.PersistentFlags().MarkDeprecated("tojson", "please use -t=json instead")
|
err := rootCmd.PersistentFlags().MarkDeprecated("tojson", "please use -o=json instead")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&outputFormat, "to-type", "t", "yaml", "[yaml|json|props] output format type.")
|
rootCmd.PersistentFlags().StringVarP(&outputFormat, "output-format", "o", "yaml", "[yaml|json|props] output format type.")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&nullInput, "null-input", "n", false, "Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.")
|
rootCmd.PersistentFlags().BoolVarP(&nullInput, "null-input", "n", false, "Don't read input, simply evaluate the expression given. Useful for creating yaml docs from scratch.")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&noDocSeparators, "no-doc", "N", false, "Don't print document separators (---)")
|
rootCmd.PersistentFlags().BoolVarP(&noDocSeparators, "no-doc", "N", false, "Don't print document separators (---)")
|
||||||
|
|
||||||
|
4
release_notes.txt
Normal file
4
release_notes.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
4.12.0:
|
||||||
|
- Can now convert yaml to properties properties format (`-o=props`), See [] for more info.
|
||||||
|
- Fixed document header/footer comment handling when merging (https://github.com/mikefarah/yq/issues/919)
|
||||||
|
- pretty print yaml 1.1 compatibility (https://github.com/mikefarah/yq/issues/914)
|
Loading…
Reference in New Issue
Block a user