shithub: hugo

Download patch

ref: 0ab41624137654a6668e026f717da2a6f3fe7334
parent: cafb784799e2e09df7345ca1d7cfcfae4d1b7aa2
author: John Ku <[email protected]>
date: Tue Dec 8 17:45:24 EST 2015

Ability to config layout and content dir via cli

fixes spf13/hugo#1598

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -143,6 +143,8 @@
 var (
 	baseURL     string
 	cacheDir    string
+	contentDir  string
+	layoutDir   string
 	cfgFile     string
 	destination string
 	logFile     string
@@ -213,6 +215,8 @@
 	cmd.Flags().BoolVar(&disableSitemap, "disableSitemap", false, "Do not build Sitemap file")
 	cmd.Flags().BoolVar(&disableRobotsTXT, "disableRobotsTXT", false, "Do not build Robots TXT file")
 	cmd.Flags().StringVarP(&source, "source", "s", "", "filesystem path to read files relative from")
+	cmd.Flags().StringVarP(&contentDir, "contentDir", "c", "", "filesystem path to content directory")
+	cmd.Flags().StringVarP(&layoutDir, "layoutDir", "l", "", "filesystem path to layout directory")
 	cmd.Flags().StringVarP(&cacheDir, "cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
 	cmd.Flags().BoolVarP(&ignoreCache, "ignoreCache", "", false, "Ignores the cache directory for reading but still writes to it")
 	cmd.Flags().StringVarP(&destination, "destination", "d", "", "filesystem path to write files to")
@@ -403,6 +407,14 @@
 	} else {
 		dir, _ := os.Getwd()
 		viper.Set("WorkingDir", dir)
+	}
+
+	if contentDir != "" {
+		viper.Set("ContentDir", contentDir)
+	}
+
+	if layoutDir != "" {
+		viper.Set("LayoutDir", layoutDir)
 	}
 
 	if cacheDir != "" {