shithub: hugo

Download patch

ref: f21b827f7b1b200b83f64a558b1b44cf6bf312e9
parent: 7c597c7d756652c3cd50f3b538559ef505d817b9
author: Bjørn Erik Pedersen <[email protected]>
date: Mon Apr 16 04:23:32 EDT 2018

commands: Re-add the missing releaser command

--- a/commands/commands.go
+++ b/commands/commands.go
@@ -49,6 +49,7 @@
 		newListCmd(),
 		newImportCmd(),
 		newGenCmd(),
+		createReleaser(),
 	)
 
 	return b
@@ -62,7 +63,11 @@
 
 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)
 	}
 }
 
@@ -108,6 +113,19 @@
 
 	// Need to get the sites once built.
 	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 {
--- a/commands/commands_test.go
+++ b/commands/commands_test.go
@@ -118,6 +118,9 @@
 		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
 		}
--- a/commands/release.go
+++ b/commands/release.go
@@ -18,10 +18,13 @@
 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 @@
 	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{
@@ -51,6 +54,14 @@
 	r.cmd.PersistentFlags().BoolVarP(&r.try, "try", "", false, "simulate a release, i.e. no changes")
 
 	return r
+}
+
+func (c *releaseCommandeer) getCommand() *cobra.Command {
+	return c.cmd
+}
+
+func (c *releaseCommandeer) flagsToConfig(cfg config.Provider) {
+
 }
 
 func (r *releaseCommandeer) release() error {
--- /dev/null
+++ b/commands/release_noop.go
@@ -1,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{}
+}