shithub: hugo

Download patch

ref: 421a46947ab5c889185422c864a9abbb7d4e2e04
parent: 0a40cb43eaa88c18e94cc5ffdb65f9047ef6265c
author: Albert Nigmatzianov <[email protected]>
date: Wed May 24 06:51:48 EDT 2017

cmd: Replace flagChanged with pflag.FlagSet.Changed

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -467,15 +467,15 @@
 	}
 
 	// Remove these in Hugo 0.23.
-	if flagChanged(cmd.Flags(), "disable404") {
+	if cmd.Flags().Changed("disable404") {
 		helpers.Deprecated("command line", "--disable404", "Use --disableKinds=404", false)
 	}
 
-	if flagChanged(cmd.Flags(), "disableRSS") {
+	if cmd.Flags().Changed("disableRSS") {
 		helpers.Deprecated("command line", "--disableRSS", "Use --disableKinds=RSS", false)
 	}
 
-	if flagChanged(cmd.Flags(), "disableSitemap") {
+	if cmd.Flags().Changed("disableSitemap") {
 		helpers.Deprecated("command line", "--disableSitemap", "Use --disableKinds=sitemap", false)
 	}
 
@@ -489,18 +489,10 @@
 }
 
 func (c *commandeer) setValueFromFlag(flags *flag.FlagSet, key string) {
-	if flagChanged(flags, key) {
+	if flags.Changed(key) {
 		f := flags.Lookup(key)
 		c.Set(key, f.Value.String())
 	}
-}
-
-func flagChanged(flags *flag.FlagSet, key string) bool {
-	flag := flags.Lookup(key)
-	if flag == nil {
-		return false
-	}
-	return flag.Changed
 }
 
 func (c *commandeer) watchConfig() {
--- a/commands/new.go
+++ b/commands/new.go
@@ -98,11 +98,11 @@
 		return err
 	}
 
-	if flagChanged(cmd.Flags(), "format") {
+	if cmd.Flags().Changed("format") {
 		c.Set("metaDataFormat", configFormat)
 	}
 
-	if flagChanged(cmd.Flags(), "editor") {
+	if cmd.Flags().Changed("editor") {
 		c.Set("newContentEditor", contentEditor)
 	}
 
--- a/commands/server.go
+++ b/commands/server.go
@@ -106,7 +106,7 @@
 		return err
 	}
 
-	if flagChanged(cmd.Flags(), "disableLiveReload") {
+	if cmd.Flags().Changed("disableLiveReload") {
 		c.Set("disableLiveReload", disableLiveReload)
 	}
 
@@ -123,7 +123,7 @@
 	if err == nil {
 		l.Close()
 	} else {
-		if flagChanged(serverCmd.Flags(), "port") {
+		if serverCmd.Flags().Changed("port") {
 			// port set explicitly by user -- he/she probably meant it!
 			return newSystemErrorF("Server startup failed: %s", err)
 		}