One more error fix in the server command

And some other small code clean-up.

See #1502
This commit is contained in:
Anthony Fok 2015-12-02 11:56:36 -07:00
parent c5287e7817
commit d48781badf
8 changed files with 26 additions and 23 deletions

View file

@ -23,7 +23,7 @@ var cpuProfilefile string
var memProfilefile string var memProfilefile string
var benchmarkTimes int var benchmarkTimes int
var benchmark = &cobra.Command{ var benchmarkCmd = &cobra.Command{
Use: "benchmark", Use: "benchmark",
Short: "Benchmark hugo by building a site a number of times.", Short: "Benchmark hugo by building a site a number of times.",
Long: `Hugo can build a site many times over and analyze the running process Long: `Hugo can build a site many times over and analyze the running process
@ -38,10 +38,10 @@ creating a benchmark.`,
} }
func init() { func init() {
benchmark.Flags().StringVar(&cpuProfilefile, "cpuprofile", "", "path/filename for the CPU profile file") benchmarkCmd.Flags().StringVar(&cpuProfilefile, "cpuprofile", "", "path/filename for the CPU profile file")
benchmark.Flags().StringVar(&memProfilefile, "memprofile", "", "path/filename for the memory profile file") benchmarkCmd.Flags().StringVar(&memProfilefile, "memprofile", "", "path/filename for the memory profile file")
benchmark.Flags().IntVarP(&benchmarkTimes, "count", "n", 13, "number of times to build the site") benchmarkCmd.Flags().IntVarP(&benchmarkTimes, "count", "n", 13, "number of times to build the site")
} }
func bench(cmd *cobra.Command, args []string) error { func bench(cmd *cobra.Command, args []string) error {

View file

@ -18,7 +18,7 @@ import (
"github.com/spf13/hugo/hugolib" "github.com/spf13/hugo/hugolib"
) )
var check = &cobra.Command{ var checkCmd = &cobra.Command{
Use: "check", Use: "check",
Short: "Check content in the source directory", Short: "Check content in the source directory",
Long: `Hugo will perform some basic analysis on the content provided Long: `Hugo will perform some basic analysis on the content provided

View file

@ -127,10 +127,10 @@ func Execute() {
// AddCommands adds child commands to the root command HugoCmd. // AddCommands adds child commands to the root command HugoCmd.
func AddCommands() { func AddCommands() {
HugoCmd.AddCommand(serverCmd) HugoCmd.AddCommand(serverCmd)
HugoCmd.AddCommand(version) HugoCmd.AddCommand(versionCmd)
HugoCmd.AddCommand(config) HugoCmd.AddCommand(configCmd)
HugoCmd.AddCommand(check) HugoCmd.AddCommand(checkCmd)
HugoCmd.AddCommand(benchmark) HugoCmd.AddCommand(benchmarkCmd)
HugoCmd.AddCommand(convertCmd) HugoCmd.AddCommand(convertCmd)
HugoCmd.AddCommand(newCmd) HugoCmd.AddCommand(newCmd)
HugoCmd.AddCommand(listCmd) HugoCmd.AddCommand(listCmd)
@ -144,7 +144,7 @@ func AddCommands() {
} }
//Initializes flags // init initializes flags.
func init() { func init() {
HugoCmd.PersistentFlags().BoolVarP(&Draft, "buildDrafts", "D", false, "include content marked as draft") HugoCmd.PersistentFlags().BoolVarP(&Draft, "buildDrafts", "D", false, "include content marked as draft")
HugoCmd.PersistentFlags().BoolVarP(&Future, "buildFuture", "F", false, "include content with publishdate in the future") HugoCmd.PersistentFlags().BoolVarP(&Future, "buildFuture", "F", false, "include content with publishdate in the future")
@ -184,7 +184,7 @@ func init() {
// This message will be shown to Windows users if Hugo is opened from explorer.exe // This message will be shown to Windows users if Hugo is opened from explorer.exe
cobra.MousetrapHelpText = ` cobra.MousetrapHelpText = `
Hugo is a command line tool Hugo is a command-line tool
You need to open cmd.exe and run it from there.` You need to open cmd.exe and run it from there.`
} }
@ -657,7 +657,8 @@ func NewWatcher(port int) error {
return nil return nil
} }
// isThemeVsHugoVersionMismatch returns whether the current Hugo version is < theme's min_version // isThemeVsHugoVersionMismatch returns whether the current Hugo version is
// less than the theme's min_version.
func isThemeVsHugoVersionMismatch() (mismatch bool, requiredMinVersion string) { func isThemeVsHugoVersionMismatch() (mismatch bool, requiredMinVersion string) {
if !helpers.ThemeSet() { if !helpers.ThemeSet() {
return return

View file

@ -22,7 +22,7 @@ import (
) )
func init() { func init() {
check.AddCommand(limit) checkCmd.AddCommand(limit)
} }
var limit = &cobra.Command{ var limit = &cobra.Command{

View file

@ -1,4 +1,4 @@
// Copyright © 2013-15 Steve Francia <spf@spf13.com>. // Copyright © 2013-2015 Steve Francia <spf@spf13.com>.
// //
// 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.
@ -21,7 +21,7 @@ import (
"sort" "sort"
) )
var config = &cobra.Command{ var configCmd = &cobra.Command{
Use: "config", Use: "config",
Short: "Print the site configuration", Short: "Print the site configuration",
Long: `Print the site configuration, both default and custom settings.`, Long: `Print the site configuration, both default and custom settings.`,

View file

@ -4,9 +4,9 @@ import (
"github.com/spf13/afero" "github.com/spf13/afero"
"github.com/spf13/hugo/hugofs" "github.com/spf13/hugo/hugofs"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"os"
"path/filepath" "path/filepath"
"testing" "testing"
"os"
) )
// Issue #1133 // Issue #1133

View file

@ -1,4 +1,4 @@
// Copyright © 2013-14 Steve Francia <spf@spf13.com>. // Copyright © 2013-2015 Steve Francia <spf@spf13.com>.
// //
// 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.
@ -94,7 +94,9 @@ func init() {
} }
func server(cmd *cobra.Command, args []string) error { func server(cmd *cobra.Command, args []string) error {
InitializeConfig() if err := InitializeConfig(); err != nil {
return err
}
if cmd.Flags().Lookup("disableLiveReload").Changed { if cmd.Flags().Lookup("disableLiveReload").Changed {
viper.Set("DisableLiveReload", disableLiveReload) viper.Set("DisableLiveReload", disableLiveReload)

View file

@ -28,7 +28,7 @@ import (
var timeLayout string // the layout for time.Time var timeLayout string // the layout for time.Time
var version = &cobra.Command{ var versionCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Print the version number of Hugo", Short: "Print the version number of Hugo",
Long: `All software has versions. This is Hugo's.`, Long: `All software has versions. This is Hugo's.`,