summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-04-16 08:23:32 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-04-16 08:23:32 +0200
commitf21b827f7b1b200b83f64a558b1b44cf6bf312e9 (patch)
tree10fd9f48e03bda6a89ed000fce10d2f17b8b46c5 /commands
parent7c597c7d756652c3cd50f3b538559ef505d817b9 (diff)
commands: Re-add the missing releaser command
Diffstat (limited to 'commands')
-rw-r--r--commands/commands.go20
-rw-r--r--commands/commands_test.go3
-rw-r--r--commands/release.go13
-rw-r--r--commands/release_noop.go20
4 files changed, 54 insertions, 2 deletions
diff --git a/commands/commands.go b/commands/commands.go
index d0cc97b85..8ba28e10d 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -49,6 +49,7 @@ func (b *commandsBuilder) addAll() *commandsBuilder {
newListCmd(),
newImportCmd(),
newGenCmd(),
+ createReleaser(),
)
return b
@@ -62,7 +63,11 @@ func (b *commandsBuilder) build() *hugoCmd {
func addCommands(root *cobra.Command, commands ...cmder) {
for _, command := range commands {
- root.AddCommand(command.getCommand())
+ cmd := command.getCommand()
+ if cmd == nil {
+ continue
+ }
+ root.AddCommand(cmd)
}
}
@@ -110,6 +115,19 @@ type hugoCmd struct {
c *commandeer
}
+var _ cmder = (*nilCommand)(nil)
+
+type nilCommand struct {
+}
+
+func (c *nilCommand) getCommand() *cobra.Command {
+ return nil
+}
+
+func (c *nilCommand) flagsToConfig(cfg config.Provider) {
+
+}
+
func (b *commandsBuilder) newHugoCmd() *hugoCmd {
cc := &hugoCmd{}
diff --git a/commands/commands_test.go b/commands/commands_test.go
index 376ca7976..907f003c0 100644
--- a/commands/commands_test.go
+++ b/commands/commands_test.go
@@ -118,6 +118,9 @@ func TestCommandsPersistentFlags(t *testing.T) {
root := b.addAll().build()
for _, c := range b.commands {
+ if c.getCommand() == nil {
+ continue
+ }
// We are only intereseted in the flag handling here.
c.getCommand().RunE = noOpRunE
}
diff --git a/commands/release.go b/commands/release.go
index a95697e49..4de165f35 100644
--- a/commands/release.go
+++ b/commands/release.go
@@ -18,10 +18,13 @@ package commands
import (
"errors"
+ "github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/releaser"
"github.com/spf13/cobra"
)
+var _ cmder = (*releaseCommandeer)(nil)
+
type releaseCommandeer struct {
cmd *cobra.Command
@@ -31,7 +34,7 @@ type releaseCommandeer struct {
try bool
}
-func createReleaser() *releaseCommandeer {
+func createReleaser() cmder {
// Note: This is a command only meant for internal use and must be run
// via "go run -tags release main.go release" on the actual code base that is in the release.
r := &releaseCommandeer{
@@ -53,6 +56,14 @@ func createReleaser() *releaseCommandeer {
return r
}
+func (c *releaseCommandeer) getCommand() *cobra.Command {
+ return c.cmd
+}
+
+func (c *releaseCommandeer) flagsToConfig(cfg config.Provider) {
+
+}
+
func (r *releaseCommandeer) release() error {
if r.version == "" {
return errors.New("must set the --rel flag to the relevant version number")
diff --git a/commands/release_noop.go b/commands/release_noop.go
new file mode 100644
index 000000000..ccf34b68e
--- /dev/null
+++ b/commands/release_noop.go
@@ -0,0 +1,20 @@
+// +build !release
+
+// Copyright 2018 The Hugo Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package commands
+
+func createReleaser() cmder {
+ return &nilCommand{}
+}