commands: Re-add the missing releaser command - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f21b827f7b1b200b83f64a558b1b44cf6bf312e9
 (DIR) parent 7c597c7d756652c3cd50f3b538559ef505d817b9
 (HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Mon, 16 Apr 2018 08:23:32 +0200
       
       commands: Re-add the missing releaser command
       
       Diffstat:
         M commands/commands.go                |      20 +++++++++++++++++++-
         M commands/commands_test.go           |       3 +++
         M commands/release.go                 |      13 ++++++++++++-
         A commands/release_noop.go            |      20 ++++++++++++++++++++
       
       4 files changed, 54 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git 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{}
        
 (DIR) diff --git 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
                        }
 (DIR) diff --git 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")
 (DIR) diff --git a/commands/release_noop.go 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{}
       +}