summaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-04-11 20:17:28 +0200
committerBjørn Erik Pedersen <[email protected]>2018-04-11 20:37:08 +0200
commit96689a5c319f720368491226f034d0ff9585217c (patch)
treef2e14fcaa31154d72d50f9b75cce78ceab9dcfbc /main.go
parente7010c1b621d68ee53411a5ba8143d07b976d9fe (diff)
downloadhugo-96689a5c319f720368491226f034d0ff9585217c.tar.gz
hugo-96689a5c319f720368491226f034d0ff9585217c.zip
commands: Make commands.Execute return a Response object
We have no global `Hugo` object no more (yay!), and there are some external tools that depends on that value. These tools need to use get that value from `Response.Result`. Note that `commands.Execute` now also takes the arguments as a string slice. This should also make it easier to use, not having to modify `os.Args`. This commit also wraps up this particular issue. Phew! Test coverage in /commands before: 14.4% Now: 53.5% Still work to do, now it is at least possible. Closes #4598
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/main.go b/main.go
index 3baf6c275..d04012111 100644
--- a/main.go
+++ b/main.go
@@ -19,22 +19,19 @@ import (
"os"
"github.com/gohugoio/hugo/commands"
- jww "github.com/spf13/jwalterweatherman"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
- commands.Execute()
+ resp := commands.Execute(os.Args[1:])
- if jww.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError) > 0 {
+ if resp.Err != nil {
+ if resp.IsUserError() {
+ resp.Cmd.Println("")
+ resp.Cmd.Println(resp.Cmd.UsageString())
+ }
os.Exit(-1)
}
- // TODO(bep) cli refactor
- /*if commands.Hugo != nil {
- if commands.Hugo.Log.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError) > 0 {
- os.Exit(-1)
- }
- }*/
}