diff --git a/cmd/root.go b/cmd/root.go index 53d60c8c..b2b0bc6a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -66,7 +66,7 @@ yq -P sample.json } rootCmd.PersistentFlags().StringVarP(&outputFormat, "output-format", "o", "auto", "[auto|a|yaml|y|json|j|props|p|xml|x] output format type.") - rootCmd.PersistentFlags().StringVarP(&inputFormat, "input-format", "p", "auto", "[auto|a|yaml|y|props|p|xml|x|toml|t] parse format for input. Note that json is a subset of yaml.") + rootCmd.PersistentFlags().StringVarP(&inputFormat, "input-format", "p", "auto", "[auto|a|yaml|y|props|p|xml|x|toml] parse format for input. Note that json is a subset of yaml.") rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredXMLPreferences.AttributePrefix, "xml-attribute-prefix", yqlib.ConfiguredXMLPreferences.AttributePrefix, "prefix for xml attributes") rootCmd.PersistentFlags().StringVar(&yqlib.ConfiguredXMLPreferences.ContentName, "xml-content-name", yqlib.ConfiguredXMLPreferences.ContentName, "name for xml content (if no attribute name is present).") diff --git a/cmd/utils.go b/cmd/utils.go index 5908564d..e8130bec 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -61,7 +61,12 @@ func initCommand(cmd *cobra.Command, args []string) (string, []string, error) { inputFormat = yqlib.FormatFromFilename(inputFilename) if outputFormat == "" || outputFormat == "auto" || outputFormat == "a" { - outputFormat = yqlib.FormatFromFilename(inputFilename) + if inputFormat == "toml" { + // toml not yet supported for output + outputFormat = "yaml" + } else { + outputFormat = yqlib.FormatFromFilename(inputFilename) + } } } else if outputFormat == "" || outputFormat == "auto" || outputFormat == "a" { // backwards compatibility -