bkli fix format selection by output filename

This commit is contained in:
Ian Gulliver
2023-07-20 09:59:29 -07:00
parent 2bcc75e24c
commit 6f0952e406
5 changed files with 19 additions and 0 deletions
+7
View File
@@ -3,7 +3,9 @@ package main
import (
"fmt"
"os"
"path/filepath"
"runtime/debug"
"strings"
"github.com/gopatchy/bkl"
"github.com/jessevdk/go-flags"
@@ -39,10 +41,15 @@ func main() {
}
format := ""
if opts.OutputFormat != nil {
format = *opts.OutputFormat
}
if format == "" && opts.OutputPath != nil {
format = strings.TrimPrefix(filepath.Ext(*opts.OutputPath), ".")
}
var docs []any
for p, path := range opts.Positional.InputPaths {
+3
View File
@@ -0,0 +1,3 @@
a: 1
b: 2
c: 3
+3
View File
@@ -0,0 +1,3 @@
a: 1
b: 10
d: 4
+4
View File
@@ -0,0 +1,4 @@
bkli -o out.json a.yaml b.yaml
echo X
cat out.json
rm -f out.json
+2
View File
@@ -0,0 +1,2 @@
X
{"a":1,"b":"$required"}