diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/commands_test.go | 5 | ||||
-rw-r--r-- | commands/hugo.go | 15 |
2 files changed, 19 insertions, 1 deletions
diff --git a/commands/commands_test.go b/commands/commands_test.go index 5173e7409..2eefaa2ea 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -57,8 +57,10 @@ func TestCommandsPersistentFlags(t *testing.T) { }{{[]string{"server", "--config=myconfig.toml", "--contentDir=mycontent", + "--disableKinds=page,home", "--layoutDir=mylayouts", "--theme=mytheme", + "--gc", "--themesDir=mythemes", "--cleanDestinationDir", "--navigateToChanged", @@ -100,7 +102,10 @@ func TestCommandsPersistentFlags(t *testing.T) { assert.Equal("mytheme", cfg.GetString("theme")) assert.Equal("mythemes", cfg.GetString("themesDir")) + assert.Equal([]string{"page", "home"}, cfg.Get("disableKinds")) + assert.True(cfg.GetBool("uglyURLs")) + assert.True(cfg.GetBool("gc")) // The flag is named i18n-warnings assert.True(cfg.GetBool("logI18nWarnings")) diff --git a/commands/hugo.go b/commands/hugo.go index 5c301c7fb..41c06c026 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -243,7 +243,20 @@ If you need to set this configuration value from the command line, set it via an if targetKey != "" { configKey = targetKey } - cfg.Set(configKey, f.Value.String()) + // Gotta love this API. + switch f.Value.Type() { + case "bool": + bv, _ := flags.GetBool(key) + cfg.Set(configKey, bv) + case "string": + cfg.Set(configKey, f.Value.String()) + case "stringSlice": + bv, _ := flags.GetStringSlice(key) + cfg.Set(configKey, bv) + default: + panic(fmt.Sprintf("update switch with %s", f.Value.Type())) + } + } } |