From 5a62b07d72b1b60259e8703155ba206e27cc42f1 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 9 Mar 2023 12:04:56 +1100 Subject: [PATCH] Use file extension to auto detect output format! --- cmd/utils.go | 3 +-- pkg/yqlib/decoder.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/utils.go b/cmd/utils.go index e37b71ae..c8ba95fa 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -70,8 +70,7 @@ func initCommand(cmd *cobra.Command, args []string) (string, []string, error) { // outputFormat = yqlib.FormatFromFilename(inputFilename) if inputFilename != "-" { - yqlib.GetLogger().Warning("yq default output is now 'auto' (based on the filename extension)") - yqlib.GetLogger().Warning("For backwards compatibility 'yaml' has been set as the output format. Please use -oy to specify yaml, or drop the -p flag.", outputFormat) + yqlib.GetLogger().Warning("yq default output is now 'auto' (based on the filename extension). Normally yq would output '%v', but for backwards compatibility 'yaml' has been set. Please use -oy to specify yaml, or drop the -p flag.", outputFormat) } outputFormat = "yaml" } diff --git a/pkg/yqlib/decoder.go b/pkg/yqlib/decoder.go index 0d80c7c8..9fba83d3 100644 --- a/pkg/yqlib/decoder.go +++ b/pkg/yqlib/decoder.go @@ -39,7 +39,7 @@ func InputFormatFromString(format string) (InputFormat, error) { case "tsv", "t": return TSVObjectInputFormat, nil default: - return 0, fmt.Errorf("unknown format '%v' please use [yaml|xml|props]", format) + return 0, fmt.Errorf("unknown format '%v' please use [yaml|json|props|csv|tsv|xml]", format) } }