Use file extension to auto detect output format!

This commit is contained in:
Mike Farah 2023-03-09 12:04:56 +11:00
parent c1a236d720
commit 5a62b07d72
2 changed files with 2 additions and 3 deletions

View File

@ -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"
}

View File

@ -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)
}
}