cmd/utils.go
changeset 135 55b4a119c7c6
parent 111 863b61d682e1
child 146 2c8c8ba13f50
--- a/cmd/utils.go	Sat May 13 12:45:52 2017 +0200
+++ b/cmd/utils.go	Sun May 14 10:52:22 2017 +0200
@@ -21,7 +21,10 @@
 )
 
 func checkOutputFormat(cmd *cobra.Command, args []string) error {
-	of := viper.GetString("output")
+	of := outputFormat
+	if of == "" {
+		of = viper.GetString("default_output")
+	}
 	switch of {
 	case "", "plain", "json", "yaml", "template", "theme":
 		return nil // Accepted
@@ -31,9 +34,12 @@
 
 // getOutputFormat return the requested output format, defaulting to "plain".
 func getOutputFormat() string {
-	of := viper.GetString("output")
+	of := outputFormat
 	if of == "" {
-		of = "plain"
+		of = viper.GetString("default_output")
+		if of == "" {
+			of = "plain"
+		}
 	}
 	// Override format if a template is provided
 	if of == "plain" {
@@ -66,16 +72,20 @@
 
 	// Initialize color mode
 	switch viper.GetString("color") {
-	case "on", "yes", "force":
+	case "on", "true", "yes", "force":
 		opt["color_mode"] = "on"
-	case "off", "no":
+	case "off", "false", "no":
 		opt["color_mode"] = "off"
 	default:
 		opt["color_mode"] = "auto"
 	}
 
 	if of == "theme" {
-		opt["name"] = outputTheme
+		if outputTheme != "" {
+			opt["name"] = outputTheme
+		} else {
+			opt["name"] = viper.GetString("default_theme")
+		}
 		opt["template_directory"] = viper.GetString("template_directory")
 	} else if of == "template" {
 		opt["template"] = outputTemplate