mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 17:33:31 +00:00
parent
56a1308044
commit
15b1e269ad
4 changed files with 26 additions and 27 deletions
|
@ -196,7 +196,7 @@ func AddCommands() {
|
||||||
HugoCmd.AddCommand(serverCmd)
|
HugoCmd.AddCommand(serverCmd)
|
||||||
HugoCmd.AddCommand(newVersionCmd().getCommand())
|
HugoCmd.AddCommand(newVersionCmd().getCommand())
|
||||||
HugoCmd.AddCommand(newEnvCmd().getCommand())
|
HugoCmd.AddCommand(newEnvCmd().getCommand())
|
||||||
HugoCmd.AddCommand(configCmd)
|
HugoCmd.AddCommand(newConfigCmd().getCommand())
|
||||||
HugoCmd.AddCommand(newCheckCmd().getCommand())
|
HugoCmd.AddCommand(newCheckCmd().getCommand())
|
||||||
HugoCmd.AddCommand(newBenchmarkCmd().getCommand())
|
HugoCmd.AddCommand(newBenchmarkCmd().getCommand())
|
||||||
HugoCmd.AddCommand(newConvertCmd().getCommand())
|
HugoCmd.AddCommand(newConvertCmd().getCommand())
|
||||||
|
|
|
@ -1,17 +1,4 @@
|
||||||
// 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.
|
|
||||||
// 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.
|
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -22,18 +22,30 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configCmd = &cobra.Command{
|
var _ cmder = (*configCmd)(nil)
|
||||||
Use: "config",
|
|
||||||
Short: "Print the site configuration",
|
type configCmd struct {
|
||||||
Long: `Print the site configuration, both default and custom settings.`,
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func (c *configCmd) getCommand() *cobra.Command {
|
||||||
configCmd.RunE = printConfig
|
return c.cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func printConfig(cmd *cobra.Command, args []string) error {
|
func newConfigCmd() *configCmd {
|
||||||
cfg, err := InitializeConfig(false, nil, 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 (c *configCmd) printConfig(cmd *cobra.Command, args []string) error {
|
||||||
|
cfg, err := InitializeConfig(false, nil, c.cmd)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -29,6 +29,10 @@ type versionCmd struct {
|
||||||
cmd *cobra.Command
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *versionCmd) getCommand() *cobra.Command {
|
||||||
|
return c.cmd
|
||||||
|
}
|
||||||
|
|
||||||
func newVersionCmd() *versionCmd {
|
func newVersionCmd() *versionCmd {
|
||||||
return &versionCmd{
|
return &versionCmd{
|
||||||
&cobra.Command{
|
&cobra.Command{
|
||||||
|
@ -43,10 +47,6 @@ func newVersionCmd() *versionCmd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *versionCmd) getCommand() *cobra.Command {
|
|
||||||
return c.cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func printHugoVersion() {
|
func printHugoVersion() {
|
||||||
if hugolib.CommitHash == "" {
|
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)
|
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
|
||||||
|
|
Loading…
Add table
Reference in a new issue