ref: 9bf223e584e115569bf2ffe64c3118e54d021a90
parent: 82a0888995dc9745a9e1c68a4f9d68a7f448c000
author: Anthony Fok <[email protected]>
date: Mon Feb 16 22:19:30 EST 2015
Quote strings in `hugo config` output Also, use ` = ` to separate keys and values if metaformatdata is "toml".
--- a/commands/list_config.go
+++ b/commands/list_config.go
@@ -1,4 +1,4 @@
-// Copyright © 2013-14 Steve Francia <[email protected]>.
+// Copyright © 2013-15 Steve Francia <[email protected]>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
+ "reflect"
"sort"
)
@@ -27,6 +28,14 @@
Run: func(cmd *cobra.Command, args []string) {
InitializeConfig()
allSettings := viper.AllSettings()
+
+ var separator string
+ if allSettings["metadataformat"] == "toml" {
+ separator = " = "
+ } else {
+ separator = ": "
+ }
+
var keys []string
for k := range allSettings {
keys = append(keys, k)
@@ -33,7 +42,12 @@
}
sort.Strings(keys)
for _, k := range keys {
- fmt.Printf("%s: %+v\n", k, allSettings[k])
+ kv := reflect.ValueOf(allSettings[k])
+ if kv.Kind() == reflect.String {
+ fmt.Printf("%s%s\"%+v\"\n", k, separator, allSettings[k])
+ } else {
+ fmt.Printf("%s%s%+v\n", k, separator, allSettings[k])
+ }
}
},
}