diff options
author | Anthony Fok <foka@debian.org> | 2015-12-02 12:00:47 -0700 |
---|---|---|
committer | Anthony Fok <foka@debian.org> | 2015-12-03 00:36:38 -0700 |
commit | 00d04774f0d9789262557af6a6465d8b6271839d (patch) | |
tree | 6ac014c9a651962d6bd17d31aa69a720aed9c599 /commands/benchmark.go | |
parent | c9526f6e3fdffe9e583e11d3513faa392576c305 (diff) |
Change most global flags into local ones
This is to ensure that only the relevant command-line flags
for a certain Hugo subcommand is shown to the end user,
reducing clutter and improving user experience.
Fixes #1624 - CLI UX: Flags shouldn't be global
Diffstat (limited to 'commands/benchmark.go')
-rw-r--r-- | commands/benchmark.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/commands/benchmark.go b/commands/benchmark.go index e83fa5506..3002297d0 100644 --- a/commands/benchmark.go +++ b/commands/benchmark.go @@ -28,23 +28,23 @@ var benchmarkCmd = &cobra.Command{ Short: "Benchmark hugo by building a site a number of times.", Long: `Hugo can build a site many times over and analyze the running process creating a benchmark.`, - RunE: func(cmd *cobra.Command, args []string) error { - if err := InitializeConfig(); err != nil { - return err - } - - return bench(cmd, args) - }, } func init() { + initCoreCommonFlags(benchmarkCmd) + benchmarkCmd.Flags().StringVar(&cpuProfilefile, "cpuprofile", "", "path/filename for the CPU profile file") benchmarkCmd.Flags().StringVar(&memProfilefile, "memprofile", "", "path/filename for the memory profile file") benchmarkCmd.Flags().IntVarP(&benchmarkTimes, "count", "n", 13, "number of times to build the site") + + benchmarkCmd.RunE = benchmark } -func bench(cmd *cobra.Command, args []string) error { +func benchmark(cmd *cobra.Command, args []string) error { + if err := InitializeConfig(benchmarkCmd); err != nil { + return err + } if memProfilefile != "" { f, err := os.Create(memProfilefile) |