cmd/utils.go
changeset 85 a4464c0b0c36
parent 83 57afac822019
child 89 3758bb5f0979
--- a/cmd/utils.go	Sun May 07 14:12:56 2017 +0200
+++ b/cmd/utils.go	Sun May 07 16:38:52 2017 +0200
@@ -22,7 +22,7 @@
 func checkOutputFormat(cmd *cobra.Command, args []string) error {
 	of := viper.GetString("output")
 	switch of {
-	case "", "plain", "json", "yaml", "template":
+	case "", "plain", "json", "yaml", "template", "theme":
 		return nil // Accepted
 	}
 	return errors.Errorf("output format '%s' not supported", of)
@@ -35,10 +35,14 @@
 		of = "plain"
 	}
 	// Override format if a template is provided
-	if of == "plain" && (outputTemplate != "" || outputTemplateFile != "") {
+	if of == "plain" {
 		// If the format is plain and there is a template option,
-		// set the format to "template".
-		of = "template"
+		// set the format to "template".  Same for "theme".
+		if outputTemplate != "" || outputTemplateFile != "" {
+			of = "template"
+		} else if outputTheme != "" {
+			of = "theme"
+		}
 	}
 	return of
 }
@@ -56,7 +60,10 @@
 		printer.ColorMode = 2
 	}
 
-	if of == "template" {
+	if of == "theme" {
+		opt["name"] = outputTheme
+		opt["template_directory"] = viper.GetString("template_directory")
+	} else if of == "template" {
 		opt["template"] = outputTemplate
 		if outputTemplateFile != "" {
 			tmpl, err := readTemplate(outputTemplateFile, viper.GetString("template_directory"))