detect inputFormat only when file is provided

This commit is contained in:
ryenus 2023-03-03 09:22:56 +08:00
parent b7561adfa6
commit ff41e9f1ed
2 changed files with 12 additions and 2 deletions

View File

@ -75,7 +75,12 @@ func evaluateAll(cmd *cobra.Command, args []string) (cmdError error) {
return err
}
decoder, err := configureDecoder(true, args[0])
inputFilename := ""
if len(args) > 0 {
inputFilename = args[0]
}
decoder, err := configureDecoder(true, inputFilename)
if err != nil {
return err
}

View File

@ -100,7 +100,12 @@ func evaluateSequence(cmd *cobra.Command, args []string) (cmdError error) {
printer := yqlib.NewPrinter(encoder, printerWriter)
decoder, err := configureDecoder(false, args[0])
inputFilename := ""
if len(args) > 0 {
inputFilename = args[0]
}
decoder, err := configureDecoder(false, inputFilename)
if err != nil {
return err
}