summaryrefslogtreecommitdiffhomepage
path: root/commands/commands.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 /commands/commands.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 'commands/commands.go')
-rw-r--r--commands/commands.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/commands/commands.go b/commands/commands.go
index aad47abcd..86486d2a4 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -22,10 +22,10 @@ import (
)
// newHugoCompleteCmd builds the complete set of Hugo CLI commands.
-func newHugoCompleteCmd() *cobra.Command {
- hugoCmd := newHugoCmd().getCommand()
- addAllCommands(hugoCmd)
- return hugoCmd
+func newHugoCompleteCmd() *hugoCmd {
+ h := newHugoCmd()
+ addAllCommands(h.getCommand())
+ return h
}
// addAllCommands adds child commands to the root command HugoCmd.
@@ -81,6 +81,9 @@ func (c *baseCmd) flagsToConfig(cfg config.Provider) {
type hugoCmd struct {
*baseBuilderCmd
+
+ // Need to get the sites once built.
+ c *commandeer
}
func newHugoCmd() *hugoCmd {
@@ -107,6 +110,7 @@ Complete documentation is available at http://gohugo.io/.`,
if err != nil {
return err
}
+ cc.c = c
return c.build()
},