Merge branch 'master' into toml

This commit is contained in:
Mike Farah
2023-03-24 16:51:44 +11:00
77 changed files with 800 additions and 143 deletions
+17 -7
View File
@@ -10,6 +10,10 @@ import (
"gopkg.in/op/go-logging.v1"
)
func isAutomaticOutputFormat() bool {
return outputFormat == "" || outputFormat == "auto" || outputFormat == "a"
}
func initCommand(cmd *cobra.Command, args []string) (string, []string, error) {
cmd.SilenceUsage = true
@@ -60,15 +64,20 @@ func initCommand(cmd *cobra.Command, args []string) (string, []string, error) {
if inputFormat == "" || inputFormat == "auto" || inputFormat == "a" {
inputFormat = yqlib.FormatFromFilename(inputFilename)
if outputFormat == "" || outputFormat == "auto" || outputFormat == "a" {
if inputFormat == "toml" {
// toml not yet supported for output
_, err := yqlib.InputFormatFromString(inputFormat)
if err != nil {
// unknown file type, default to yaml
yqlib.GetLogger().Debug("Unknown file format extension '%v', defaulting to yaml", inputFormat)
inputFormat = "yaml"
if isAutomaticOutputFormat() {
outputFormat = "yaml"
} else {
outputFormat = yqlib.FormatFromFilename(inputFilename)
}
} else if isAutomaticOutputFormat() {
// automatic input worked, we can do it for output too unless specified
outputFormat = inputFormat
}
} else if outputFormat == "" || outputFormat == "auto" || outputFormat == "a" {
} else if isAutomaticOutputFormat() {
// backwards compatibility -
// before this was introduced, `yq -pcsv things.csv`
// would produce *yaml* output.
@@ -85,7 +94,8 @@ func initCommand(cmd *cobra.Command, args []string) (string, []string, error) {
if err != nil {
return "", nil, err
}
yqlib.GetLogger().Debug("Using outputformat %v", outputFormat)
yqlib.GetLogger().Debug("Using input format %v", inputFormat)
yqlib.GetLogger().Debug("Using output format %v", outputFormat)
if outputFormatType == yqlib.YamlOutputFormat ||
outputFormatType == yqlib.PropsOutputFormat {
+1 -1
View File
@@ -11,7 +11,7 @@ var (
GitDescribe string
// Version is main version number that is being run at the moment.
Version = "v4.31.2"
Version = "v4.32.2"
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release