From 7fa2b20b48b734feb640a46fc65bb749d31c2ffd Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 9 Jan 2021 12:23:06 +1100 Subject: [PATCH] Error when passing files and using null-input flag --- cmd/evaluate_all_command.go | 4 ++++ cmd/evalute_sequence_command.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/evaluate_all_command.go b/cmd/evaluate_all_command.go index 0942380a..68c9a14d 100644 --- a/cmd/evaluate_all_command.go +++ b/cmd/evaluate_all_command.go @@ -59,6 +59,10 @@ func evaluateAll(cmd *cobra.Command, args []string) error { defer func() { writeInPlaceHandler.FinishWriteInPlace(completedSuccessfully) }() } + if nullInput && len(args) > 1 { + return errors.New("Cannot pass files in when using null-input flag") + } + printer := yqlib.NewPrinter(out, outputToJSON, unwrapScalar, colorsEnabled, indent, !noDocSeparators) allAtOnceEvaluator := yqlib.NewAllAtOnceEvaluator() diff --git a/cmd/evalute_sequence_command.go b/cmd/evalute_sequence_command.go index 2e67687e..9d4a77a7 100644 --- a/cmd/evalute_sequence_command.go +++ b/cmd/evalute_sequence_command.go @@ -83,6 +83,10 @@ func evaluateSequence(cmd *cobra.Command, args []string) error { streamEvaluator := yqlib.NewStreamEvaluator() + if nullInput && len(args) > 1 { + return errors.New("Cannot pass files in when using null-input flag") + } + switch len(args) { case 0: if pipingStdIn {