Add clock cli flag

Close #8787
This commit is contained in:
satotake
2022-04-27 02:57:04 +09:00
committed by Bjørn Erik Pedersen
parent f2946da9e8
commit e77ca3c105
26 changed files with 193 additions and 37 deletions

View File

@@ -33,6 +33,7 @@ import (
"github.com/gohugoio/hugo/hugofs/files"
"github.com/gohugoio/hugo/tpl"
"github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/hugofs"
@@ -187,6 +188,7 @@ func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
"buildDrafts",
"buildFuture",
"buildExpired",
"clock",
"uglyURLs",
"canonifyURLs",
"enableRobotsTXT",
@@ -679,7 +681,7 @@ func (c *commandeer) firstPathSpec() *helpers.PathSpec {
}
func (c *commandeer) timeTrack(start time.Time, name string) {
elapsed := time.Since(start)
elapsed := htime.Since(start)
c.logger.Printf("%s in %v ms", name, int(1000*elapsed.Seconds()))
}
@@ -790,7 +792,7 @@ func (c *commandeer) fullRebuild(changeType string) {
time.Sleep(2 * time.Second)
}()
defer c.timeTrack(time.Now(), "Rebuilt")
defer c.timeTrack(htime.Now(), "Rebuilt")
c.commandeerHugoState = newCommandeerHugoState()
err := c.loadConfig()
@@ -900,7 +902,7 @@ func (c *commandeer) printChangeDetected(typ string) {
c.logger.Println(msg)
const layout = "2006-01-02 15:04:05.000 -0700"
c.logger.Println(time.Now().Format(layout))
c.logger.Println(htime.Now().Format(layout))
}
const (
@@ -1135,7 +1137,7 @@ func (c *commandeer) handleEvents(watcher *watcher.Batcher,
c.changeDetector.PrepareNew()
func() {
defer c.timeTrack(time.Now(), "Total")
defer c.timeTrack(htime.Now(), "Total")
if err := c.rebuildSites(dynamicEvents); err != nil {
c.handleBuildErr(err, "Rebuild failed")
}