URI: 
       commands: Start of flag cleaning - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 1157fef85908ea54883fe0dba6adc4861ba02162
   DIR parent e614d8a57c2ff5eef9270d51fcc6518398d7ff88
  HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Mon,  9 Apr 2018 17:20:18 +0200
       
       commands: Start of flag cleaning
       
       See #4598
       
       Diffstat:
         M commands/benchmark.go               |       1 -
         M commands/commandeer.go              |      36 +------------------------------
         M commands/hugo.go                    |      90 ++++++++++++++++++++-----------
         M commands/server.go                  |       1 +
       
       4 files changed, 61 insertions(+), 67 deletions(-)
       ---
   DIR diff --git a/commands/benchmark.go b/commands/benchmark.go
       @@ -49,7 +49,6 @@ func init() {
        
        func benchmark(cmd *cobra.Command, args []string) error {
                cfgInit := func(c *commandeer) error {
       -                c.Set("renderToMemory", renderToMemory)
                        return nil
                }
                c, err := InitializeConfig(false, cfgInit, benchmarkCmd)
   DIR diff --git a/commands/commandeer.go b/commands/commandeer.go
       @@ -143,42 +143,8 @@ func (c *commandeer) loadConfig(running bool) error {
                                initializeFlags(cmdV, cfg)
                        }
        
       -                if baseURL != "" {
       -                        cfg.Set("baseURL", baseURL)
       -                }
       -
       -                if len(disableKinds) > 0 {
       -                        cfg.Set("disableKinds", disableKinds)
       -                }
       -
       -                cfg.Set("logI18nWarnings", logI18nWarnings)
       -
       -                if theme != "" {
       -                        cfg.Set("theme", theme)
       -                }
       -
       -                if themesDir != "" {
       -                        cfg.Set("themesDir", themesDir)
       -                }
       -
       -                if destination != "" {
       -                        cfg.Set("publishDir", destination)
       -                }
       -
                        cfg.Set("workingDir", dir)
        
       -                if contentDir != "" {
       -                        cfg.Set("contentDir", contentDir)
       -                }
       -
       -                if layoutDir != "" {
       -                        cfg.Set("layoutDir", layoutDir)
       -                }
       -
       -                if cacheDir != "" {
       -                        cfg.Set("cacheDir", cacheDir)
       -                }
       -
                        return nil
                }
        
       @@ -244,7 +210,7 @@ func (c *commandeer) loadConfig(running bool) error {
                        return err
                }
        
       -        cacheDir = config.GetString("cacheDir")
       +        cacheDir := config.GetString("cacheDir")
                if cacheDir != "" {
                        if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] {
                                cacheDir = cacheDir + helpers.FilePathSeparator
   DIR diff --git a/commands/hugo.go b/commands/hugo.go
       @@ -129,7 +129,6 @@ Complete documentation is available at http://gohugo.io/.`,
                                if buildWatch {
                                        c.Set("disableLiveReload", true)
                                }
       -                        c.Set("renderToMemory", renderToMemory)
                                return nil
                        }
        
       @@ -144,31 +143,34 @@ Complete documentation is available at http://gohugo.io/.`,
        
        var hugoCmdV *cobra.Command
        
       +type flagVals struct {
       +}
       +
        // Flags that are to be added to commands.
        var (
       -        buildWatch     bool
       -        logging        bool
       -        renderToMemory bool // for benchmark testing
       -        verbose        bool
       -        verboseLog     bool
       -        debug          bool
       -        quiet          bool
       +        // TODO(bep) var vs string
       +        buildWatch bool
       +        logging    bool
       +        verbose    bool
       +        verboseLog bool
       +        debug      bool
       +        quiet      bool
        )
        
        var (
       -        gc              bool
       -        baseURL         string
       -        cacheDir        string
       -        contentDir      string
       -        layoutDir       string
       -        cfgFile         string
       -        destination     string
       -        logFile         string
       -        theme           string
       -        themesDir       string
       -        source          string
       -        logI18nWarnings bool
       -        disableKinds    []string
       +        gc      bool
       +        baseURL string
       +        //cacheDir        string
       +        //contentDir      string
       +        //layoutDir       string
       +        cfgFile string
       +        //destination     string
       +        logFile string
       +        //theme           string
       +        //themesDir       string
       +        source string
       +        //logI18nWarnings bool
       +        //disableKinds []string
        )
        
        // Execute adds all child commands to the root command HugoCmd and sets flags appropriately.
       @@ -234,13 +236,13 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
                cmd.Flags().BoolP("buildFuture", "F", false, "include content with publishdate in the future")
                cmd.Flags().BoolP("buildExpired", "E", false, "include expired content")
                cmd.Flags().StringVarP(&source, "source", "s", "", "filesystem path to read files relative from")
       -        cmd.Flags().StringVarP(&contentDir, "contentDir", "c", "", "filesystem path to content directory")
       -        cmd.Flags().StringVarP(&layoutDir, "layoutDir", "l", "", "filesystem path to layout directory")
       -        cmd.Flags().StringVarP(&cacheDir, "cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
       +        cmd.Flags().StringP("contentDir", "c", "", "filesystem path to content directory")
       +        cmd.Flags().StringP("layoutDir", "l", "", "filesystem path to layout directory")
       +        cmd.Flags().StringP("cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
                cmd.Flags().BoolP("ignoreCache", "", false, "ignores the cache directory")
       -        cmd.Flags().StringVarP(&destination, "destination", "d", "", "filesystem path to write files to")
       -        cmd.Flags().StringVarP(&theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
       -        cmd.Flags().StringVarP(&themesDir, "themesDir", "", "", "filesystem path to themes directory")
       +        cmd.Flags().StringP("destination", "d", "", "filesystem path to write files to")
       +        cmd.Flags().StringP("theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
       +        cmd.Flags().StringP("themesDir", "", "", "filesystem path to themes directory")
                cmd.Flags().Bool("uglyURLs", false, "(deprecated) if true, use /filename.html instead of /filename/")
                cmd.Flags().Bool("canonifyURLs", false, "(deprecated) if true, all relative URLs will be canonicalized using baseURL")
                cmd.Flags().StringVarP(&baseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. http://spf13.com/")
       @@ -255,9 +257,9 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
                cmd.Flags().BoolP("forceSyncStatic", "", false, "copy all files when static is changed.")
                cmd.Flags().BoolP("noTimes", "", false, "don't sync modification time of files")
                cmd.Flags().BoolP("noChmod", "", false, "don't sync permission mode of files")
       -        cmd.Flags().BoolVarP(&logI18nWarnings, "i18n-warnings", "", false, "print missing translations")
       +        cmd.Flags().BoolP("i18n-warnings", "", false, "print missing translations")
        
       -        cmd.Flags().StringSliceVar(&disableKinds, "disableKinds", []string{}, "disable different kind of pages (home, RSS etc.)")
       +        cmd.Flags().StringSlice("disableKinds", []string{}, "disable different kind of pages (home, RSS etc.)")
        
                // Set bash-completion.
                // Each flag must first be defined before using the SetAnnotation() call.
       @@ -268,7 +270,7 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
        }
        
        func initBenchmarkBuildingFlags(cmd *cobra.Command) {
       -        cmd.Flags().BoolVar(&renderToMemory, "renderToMemory", false, "render to memory (only useful for benchmark testing)")
       +        cmd.Flags().Bool("renderToMemory", false, "render to memory (only useful for benchmark testing)")
        }
        
        // init initializes flags.
       @@ -349,7 +351,12 @@ func createLogger(cfg config.Provider) (*jww.Notepad, error) {
        }
        
        func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
       -        persFlagKeys := []string{"debug", "verbose", "logFile"}
       +        persFlagKeys := []string{
       +                "debug",
       +                "verbose",
       +                "logFile",
       +                // Moved from vars
       +        }
                flagKeys := []string{
                        "cleanDestinationDir",
                        "buildDrafts",
       @@ -367,6 +374,27 @@ func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
                        "noChmod",
                        "templateMetrics",
                        "templateMetricsHints",
       +
       +                // Moved from vars.
       +                "baseURL ",
       +                "buildWatch",
       +                "cacheDir",
       +                "cfgFile",
       +                "contentDir",
       +                "debug",
       +                "destination",
       +                "disableKinds",
       +                "gc",
       +                "layoutDir",
       +                "logFile",
       +                "logI18nWarnings",
       +                "quiet",
       +                "renderToMemory",
       +                "source",
       +                "theme",
       +                "themesDir",
       +                "verbose",
       +                "verboseLog",
                }
        
                for _, key := range persFlagKeys {
   DIR diff --git a/commands/server.go b/commands/server.go
       @@ -116,6 +116,7 @@ var serverPorts []int
        
        func server(cmd *cobra.Command, args []string) error {
                // If a Destination is provided via flag write to disk
       +        destination, _ := cmd.Flags().GetString("destination")
                if destination != "" {
                        renderToDisk = true
                }