diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-10 09:19:26 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-04-11 09:50:19 +0200 |
commit | 4d32f2fa8969f368b088dc9bcedb45f2c986cb27 (patch) | |
tree | a091c49f6011605f08b92b9dbdb2d2acdd87f9ce /commands/benchmark.go | |
parent | 018602c46db8d729af2871bd5f4c1e7480420f09 (diff) |
commands: Make the hugo command non-global
See #4598
Diffstat (limited to 'commands/benchmark.go')
-rw-r--r-- | commands/benchmark.go | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/commands/benchmark.go b/commands/benchmark.go index ae5d436e8..b1291cc45 100644 --- a/commands/benchmark.go +++ b/commands/benchmark.go @@ -23,22 +23,12 @@ import ( jww "github.com/spf13/jwalterweatherman" ) -var _ cmder = (*benchmarkCmd)(nil) - type benchmarkCmd struct { benchmarkTimes int cpuProfileFile string memProfileFile string - cmd *cobra.Command -} - -type cmder interface { - getCommand() *cobra.Command -} - -func (c *benchmarkCmd) getCommand() *cobra.Command { - return c.cmd + *baseBuilderCmd } func newBenchmarkCmd() *benchmarkCmd { @@ -49,15 +39,14 @@ func newBenchmarkCmd() *benchmarkCmd { creating a benchmark.`, } - initHugoBuilderFlags(cmd) - initBenchmarkBuildingFlags(cmd) - - c := &benchmarkCmd{cmd: cmd} + c := &benchmarkCmd{baseBuilderCmd: newBuilderCmd(cmd)} cmd.Flags().StringVar(&c.cpuProfileFile, "cpuprofile", "", "path/filename for the CPU profile file") cmd.Flags().StringVar(&c.memProfileFile, "memprofile", "", "path/filename for the memory profile file") cmd.Flags().IntVarP(&c.benchmarkTimes, "count", "n", 13, "number of times to build the site") + cmd.Flags().Bool("renderToMemory", false, "render to memory (only useful for benchmark testing)") + cmd.RunE = c.benchmark return c @@ -67,7 +56,7 @@ func (c *benchmarkCmd) benchmark(cmd *cobra.Command, args []string) error { cfgInit := func(c *commandeer) error { return nil } - comm, err := InitializeConfig(false, cfgInit, c.cmd) + comm, err := initializeConfig(false, &c.hugoBuilderCommon, c, cfgInit) if err != nil { return err } |