commands: Remove accidental and breaking space in baseURL flag
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 15 Apr 2018 07:46:02 +0000 (09:46 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 15 Apr 2018 09:20:04 +0000 (11:20 +0200)
And added key-trimming to prevent future mishaps.

See #4607

commands/commands_test.go
commands/hugo.go

index 2eefaa2ea2fb7fad3e7ac17e1afbacd442aaa59f..376ca7976fbb0eea029362e8527773cc973147d1 100644 (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"))
 
index 41c06c026b98ded90db5d1747e45b07a008e7f69..e2d447768fd9c83bfe8b27d114a5cfd1e4eefb9d 100644 (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.