mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
commands: Cleanup the hugo config command
Most importantly filter out some keys not relevant for the end user. See #6144
This commit is contained in:
parent
4b6c5eba30
commit
45ee8a7a52
1 changed files with 12 additions and 4 deletions
|
@ -15,7 +15,9 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
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()
|
allSettings := cfg.Cfg.(*viper.Viper).AllSettings()
|
||||||
|
|
||||||
var separator string
|
// We need to clean up this, but we store objects in the config that
|
||||||
if allSettings["metadataformat"] == "toml" {
|
// 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 = " = "
|
separator = " = "
|
||||||
} else {
|
|
||||||
separator = ": "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
for k := range allSettings {
|
for k := range allSettings {
|
||||||
|
if ignoreKeysRe.MatchString(k) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
Loading…
Reference in a new issue