commands: Remove accidental and breaking space in baseURL flag

And added key-trimming to prevent future mishaps.

See #4607
This commit is contained in:
Bjørn Erik Pedersen 2018-04-15 09:46:02 +02:00
parent 27a524b090
commit 1b4e0c4161
2 changed files with 3 additions and 1 deletions

View file

@ -101,6 +101,7 @@ func TestCommandsPersistentFlags(t *testing.T) {
assert.Equal("mylayouts", cfg.GetString("layoutDir"))
assert.Equal("mytheme", cfg.GetString("theme"))
assert.Equal("mythemes", cfg.GetString("themesDir"))
assert.Equal("https://example.com/b/", cfg.GetString("baseURL"))
assert.Equal([]string{"page", "home"}, cfg.Get("disableKinds"))

View file

@ -189,7 +189,7 @@ func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
"templateMetricsHints",
// Moved from vars.
"baseURL ",
"baseURL",
"buildWatch",
"cacheDir",
"cfgFile",
@ -231,6 +231,7 @@ var deprecatedFlags = map[string]bool{
}
func setValueFromFlag(flags *flag.FlagSet, key string, cfg config.Provider, targetKey string) {
key = strings.TrimSpace(key)
if flags.Changed(key) {
if _, deprecated := deprecatedFlags[strings.ToLower(key)]; deprecated {
msg := fmt.Sprintf(`Set "%s = true" in your config.toml.