commands: Make the --poll flag a duration

So you can do:

```
hugo server --poll 700ms
```

See #8720
This commit is contained in:
Bjørn Erik Pedersen
2021-07-05 10:13:41 +02:00
parent 43a23239b2
commit e31b1d1946
9 changed files with 56 additions and 18 deletions

View File

@@ -29,6 +29,8 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/common/constants"
@@ -523,13 +525,9 @@ But this also means that your site configuration may not do what you expect. If
timeout := 30 * time.Second
if cfg.Language.IsSet("timeout") {
v := cfg.Language.Get("timeout")
if n := cast.ToInt(v); n > 0 {
timeout = time.Duration(n) * time.Millisecond
} else {
d, err := time.ParseDuration(cast.ToString(v))
if err == nil {
timeout = d
}
d, err := types.ToDurationE(v)
if err == nil {
timeout = d
}
}