summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorJohn Ku <john.cmyk@gmail.com>2015-12-08 22:45:24 -0800
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-11 23:42:27 +0100
commit0ab41624137654a6668e026f717da2a6f3fe7334 (patch)
treed49c0a84b01c6b9bbfaef181b8285363de164f56 /commands
parentcafb784799e2e09df7345ca1d7cfcfae4d1b7aa2 (diff)
Ability to config layout and content dir via cli
fixes spf13/hugo#1598
Diffstat (limited to 'commands')
-rw-r--r--commands/hugo.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 7ecf6d7c3..daf483923 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -143,6 +143,8 @@ var (
var (
baseURL string
cacheDir string
+ contentDir string
+ layoutDir string
cfgFile string
destination string
logFile string
@@ -213,6 +215,8 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
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")
@@ -405,6 +409,14 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
viper.Set("WorkingDir", dir)
}
+ if contentDir != "" {
+ viper.Set("ContentDir", contentDir)
+ }
+
+ if layoutDir != "" {
+ viper.Set("LayoutDir", layoutDir)
+ }
+
if cacheDir != "" {
if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] {
cacheDir = cacheDir + helpers.FilePathSeparator