bkli fix format selection by output filename
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
a: 1
|
||||
b: 2
|
||||
c: 3
|
||||
@@ -0,0 +1,3 @@
|
||||
a: 1
|
||||
b: 10
|
||||
d: 4
|
||||
@@ -0,0 +1,4 @@
|
||||
bkli -o out.json a.yaml b.yaml
|
||||
echo X
|
||||
cat out.json
|
||||
rm -f out.json
|
||||
@@ -0,0 +1,2 @@
|
||||
X
|
||||
{"a":1,"b":"$required"}
|
||||
Reference in New Issue
Block a user