madonctl version: Do not use theme for now
authorMikael Berthe <mikael@lilotux.net>
Fri, 26 May 2017 13:41:58 +0200
changeset 146 2c8c8ba13f50
parent 145 0f6b8411ad36
child 147 d9b02148d24c
madonctl version: Do not use theme for now Version theme cannot fallback to default output if the theme template is missing, so only allow templates for now.
cmd/utils.go
cmd/version.go
--- a/cmd/utils.go	Fri May 26 12:05:50 2017 +0200
+++ b/cmd/utils.go	Fri May 26 13:41:58 2017 +0200
@@ -41,15 +41,12 @@
 			of = "plain"
 		}
 	}
-	// Override format if a template is provided
-	if of == "plain" {
-		// If the format is plain and there is a template option,
-		// set the format to "template".  Same for "theme".
-		if outputTemplate != "" || outputTemplateFile != "" {
-			of = "template"
-		} else if outputTheme != "" {
-			of = "theme"
-		}
+
+	// Override format if a template or a theme is provided
+	if outputTemplate != "" || outputTemplateFile != "" {
+		of = "template"
+	} else if outputTheme != "" {
+		of = "theme"
 	}
 	return of
 }
--- a/cmd/version.go	Fri May 26 12:05:50 2017 +0200
+++ b/cmd/version.go	Fri May 26 13:41:58 2017 +0200
@@ -39,11 +39,12 @@
 		}
 		var p printer.ResourcePrinter
 		var err error
-		if getOutputFormat() == "plain" {
+		of := getOutputFormat()
+		if of == "template" {
+			p, err = getPrinter()
+		} else { // Default
 			pOptions := printer.Options{"template": versionTemplate}
 			p, err = printer.NewPrinterTemplate(pOptions)
-		} else {
-			p, err = getPrinter()
 		}
 		if err != nil {
 			errPrint("Error: %s", err.Error())