summaryrefslogtreecommitdiffstats
path: root/commands/config.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-01-31 09:09:11 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-01-31 16:36:36 +0100
commit2bbc865f7bb713b2d0d2dbb02b90ae2621ad5367 (patch)
treecda2d88ec0079293780028d3f0fe699f839777e7 /commands/config.go
parent0792cfa9fae94a06a31e393a46fed3b1dd73b66a (diff)
commands: Fix config environment handling
Fixes #6503 Fixes #6824
Diffstat (limited to 'commands/config.go')
-rw-r--r--commands/config.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/commands/config.go b/commands/config.go
index 72c2a0d97..37bf45e3c 100644
--- a/commands/config.go
+++ b/commands/config.go
@@ -15,6 +15,7 @@ package commands
import (
"encoding/json"
+ "fmt"
"os"
"reflect"
"regexp"
@@ -27,27 +28,23 @@ import (
"github.com/gohugoio/hugo/modules"
"github.com/spf13/cobra"
- jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
var _ cmder = (*configCmd)(nil)
type configCmd struct {
- hugoBuilderCommon
- *baseCmd
+ *baseBuilderCmd
}
-func newConfigCmd() *configCmd {
+func (b *commandsBuilder) newConfigCmd() *configCmd {
cc := &configCmd{}
- cc.baseCmd = newBaseCmd(&cobra.Command{
+ cmd := &cobra.Command{
Use: "config",
Short: "Print the site configuration",
Long: `Print the site configuration, both default and custom settings.`,
RunE: cc.printConfig,
- })
-
- cc.cmd.PersistentFlags().StringVarP(&cc.source, "source", "s", "", "filesystem path to read files relative from")
+ }
printMountsCmd := &cobra.Command{
Use: "mounts",
@@ -55,7 +52,9 @@ func newConfigCmd() *configCmd {
RunE: cc.printMounts,
}
- cc.cmd.AddCommand(printMountsCmd)
+ cmd.AddCommand(printMountsCmd)
+
+ cc.baseBuilderCmd = b.newBuilderBasicCmd(cmd)
return cc
}
@@ -105,9 +104,9 @@ func (c *configCmd) printConfig(cmd *cobra.Command, args []string) error {
for _, k := range keys {
kv := reflect.ValueOf(allSettings[k])
if kv.Kind() == reflect.String {
- jww.FEEDBACK.Printf("%s%s\"%+v\"\n", k, separator, allSettings[k])
+ fmt.Printf("%s%s\"%+v\"\n", k, separator, allSettings[k])
} else {
- jww.FEEDBACK.Printf("%s%s%+v\n", k, separator, allSettings[k])
+ fmt.Printf("%s%s%+v\n", k, separator, allSettings[k])
}
}