summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-07-31 09:59:32 +0200
committerBjørn Erik Pedersen <[email protected]>2019-07-31 12:10:05 +0200
commit45ee8a7a52213bf394c7f41a72be78084ddc789a (patch)
tree845b5648cd0927d2d1d0c03bc42b6d435cbaa3f6
parent4b6c5eba306e6e69f3dd07a6c102bfc8040b38c9 (diff)
downloadhugo-45ee8a7a52213bf394c7f41a72be78084ddc789a.tar.gz
hugo-45ee8a7a52213bf394c7f41a72be78084ddc789a.zip
commands: Cleanup the hugo config command
Most importantly filter out some keys not relevant for the end user. See #6144
-rw-r--r--commands/config.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/commands/config.go b/commands/config.go
index 33a61733d..64f0cdbbf 100644
--- a/commands/config.go
+++ b/commands/config.go
@@ -15,7 +15,9 @@ package commands
import (
"reflect"
+ "regexp"
"sort"
+ "strings"
"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
@@ -52,15 +54,21 @@ func (c *configCmd) printConfig(cmd *cobra.Command, args []string) error {
allSettings := cfg.Cfg.(*viper.Viper).AllSettings()
- var separator string
- if allSettings["metadataformat"] == "toml" {
+ // We need to clean up this, but we store objects in the config that
+ // isn't really interesting to the end user, so filter these.
+ ignoreKeysRe := regexp.MustCompile("client|sorted|filecacheconfigs|allmodules|multilingual")
+
+ separator := ": "
+
+ if len(cfg.configFiles) > 0 && strings.HasSuffix(cfg.configFiles[0], ".toml") {
separator = " = "
- } else {
- separator = ": "
}
var keys []string
for k := range allSettings {
+ if ignoreKeysRe.MatchString(k) {
+ continue
+ }
keys = append(keys, k)
}
sort.Strings(keys)