diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-04-09 20:05:09 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-04-11 09:48:56 +0200 |
commit | 15b1e269ade91ddc6a74c552bc61b0c5e527d268 (patch) | |
tree | 261a04a264722efffaee1edbf46f5660971bfa8d /commands | |
parent | 56a13080446283ed1cde6b69fc6f4fac85076c84 (diff) | |
download | hugo-15b1e269ade91ddc6a74c552bc61b0c5e527d268.tar.gz hugo-15b1e269ade91ddc6a74c552bc61b0c5e527d268.zip |
comands: Make the config command non-global
See #4598
Diffstat (limited to 'commands')
-rw-r--r-- | commands/hugo.go | 2 | ||||
-rw-r--r-- | commands/limit_darwin.go | 15 | ||||
-rw-r--r-- | commands/list_config.go | 28 | ||||
-rw-r--r-- | commands/version.go | 8 |
4 files changed, 26 insertions, 27 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 1237eaea1..3a45c3046 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -196,7 +196,7 @@ func AddCommands() { HugoCmd.AddCommand(serverCmd) HugoCmd.AddCommand(newVersionCmd().getCommand()) HugoCmd.AddCommand(newEnvCmd().getCommand()) - HugoCmd.AddCommand(configCmd) + HugoCmd.AddCommand(newConfigCmd().getCommand()) HugoCmd.AddCommand(newCheckCmd().getCommand()) HugoCmd.AddCommand(newBenchmarkCmd().getCommand()) HugoCmd.AddCommand(newConvertCmd().getCommand()) diff --git a/commands/limit_darwin.go b/commands/limit_darwin.go index e35c24de4..bc5f42a57 100644 --- a/commands/limit_darwin.go +++ b/commands/limit_darwin.go @@ -1,17 +1,4 @@ -// Copyright 2015 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. - -// Copyright 2015 The Hugo Authors. All rights reserved. +// 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. diff --git a/commands/list_config.go b/commands/list_config.go index 031bff73f..b03991592 100644 --- a/commands/list_config.go +++ b/commands/list_config.go @@ -22,18 +22,30 @@ import ( "github.com/spf13/viper" ) -var configCmd = &cobra.Command{ - Use: "config", - Short: "Print the site configuration", - Long: `Print the site configuration, both default and custom settings.`, +var _ cmder = (*configCmd)(nil) + +type configCmd struct { + cmd *cobra.Command +} + +func (c *configCmd) getCommand() *cobra.Command { + return c.cmd } -func init() { - configCmd.RunE = printConfig +func newConfigCmd() *configCmd { + cc := &configCmd{} + cc.cmd = &cobra.Command{ + Use: "config", + Short: "Print the site configuration", + Long: `Print the site configuration, both default and custom settings.`, + RunE: cc.printConfig, + } + + return cc } -func printConfig(cmd *cobra.Command, args []string) error { - cfg, err := InitializeConfig(false, nil, configCmd) +func (c *configCmd) printConfig(cmd *cobra.Command, args []string) error { + cfg, err := InitializeConfig(false, nil, c.cmd) if err != nil { return err diff --git a/commands/version.go b/commands/version.go index 978a5440d..4498c3611 100644 --- a/commands/version.go +++ b/commands/version.go @@ -29,6 +29,10 @@ type versionCmd struct { cmd *cobra.Command } +func (c *versionCmd) getCommand() *cobra.Command { + return c.cmd +} + func newVersionCmd() *versionCmd { return &versionCmd{ &cobra.Command{ @@ -43,10 +47,6 @@ func newVersionCmd() *versionCmd { } } -func (c *versionCmd) getCommand() *cobra.Command { - return c.cmd -} - func printHugoVersion() { if hugolib.CommitHash == "" { jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate) |