mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-07 14:25:38 +00:00
Compare commits
1 Commits
2a90498509
...
7f9905631f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f9905631f |
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
setUp() {
|
setUp() {
|
||||||
rm test*.yml || true
|
rm test*.yml || true
|
||||||
rm -rf test_dir* || true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testBasicSplitWithName() {
|
testBasicSplitWithName() {
|
||||||
@ -205,23 +204,4 @@ EOM
|
|||||||
assertEquals "$expectedDoc3" "$doc3"
|
assertEquals "$expectedDoc3" "$doc3"
|
||||||
}
|
}
|
||||||
|
|
||||||
testSplitWithDirectories() {
|
source ./scripts/shunit2
|
||||||
cat >test.yml <<EOL
|
|
||||||
f: test_dir1/file1
|
|
||||||
---
|
|
||||||
f: test_dir2/dir22/file2
|
|
||||||
---
|
|
||||||
f: file3
|
|
||||||
EOL
|
|
||||||
|
|
||||||
./yq e --no-doc -s ".f" test.yml
|
|
||||||
|
|
||||||
doc1=$(cat test_dir1/file1.yml)
|
|
||||||
assertEquals "f: test_dir1/file1" "$doc1"
|
|
||||||
doc2=$(cat test_dir2/dir22/file2.yml)
|
|
||||||
assertEquals "f: test_dir2/dir22/file2" "$doc2"
|
|
||||||
doc3=$(cat file3.yml)
|
|
||||||
assertEquals "f: file3" "$doc3"
|
|
||||||
}
|
|
||||||
|
|
||||||
source ./scripts/shunit2
|
|
||||||
@ -197,7 +197,7 @@ yq -P -oy sample.json
|
|||||||
}
|
}
|
||||||
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredYamlPreferences.LeadingContentPreProcessing, "header-preprocess", "", true, "Slurp any header comments and separators before processing expression.")
|
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredYamlPreferences.LeadingContentPreProcessing, "header-preprocess", "", true, "Slurp any header comments and separators before processing expression.")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&splitFileExp, "split-exp", "s", "", "print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.")
|
rootCmd.PersistentFlags().StringVarP(&splitFileExp, "split-exp", "s", "", "print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter.")
|
||||||
if err = rootCmd.RegisterFlagCompletionFunc("split-exp", cobra.NoFileCompletions); err != nil {
|
if err = rootCmd.RegisterFlagCompletionFunc("split-exp", cobra.NoFileCompletions); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,10 +70,6 @@ func (sp *multiPrintWriter) GetWriter(node *CandidateNode) (*bufio.Writer, error
|
|||||||
name = fmt.Sprintf("%v.%v", name, sp.extension)
|
name = fmt.Sprintf("%v.%v", name, sp.extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(filepath.Dir(name), 0750)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
f, err := os.Create(name)
|
f, err := os.Create(name)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user