mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 06:30:33 +03:00
Clean flags
* Reduce the amount of global flags * Unexport all flag vars and commands vars * Some other minor flag cleaning
This commit is contained in:
parent
bd0176a548
commit
87ca0d0cbe
5 changed files with 171 additions and 124 deletions
|
@ -32,12 +32,14 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var serverPort int
|
||||
var serverInterface string
|
||||
var serverWatch bool
|
||||
var serverAppend bool
|
||||
var disableLiveReload bool
|
||||
var renderToDisk bool
|
||||
var (
|
||||
disableLiveReload bool
|
||||
renderToDisk bool
|
||||
serverAppend bool
|
||||
serverInterface string
|
||||
serverPort int
|
||||
serverWatch bool
|
||||
)
|
||||
|
||||
//var serverCmdV *cobra.Command
|
||||
|
||||
|
@ -81,14 +83,14 @@ func (f noDirFile) Readdir(count int) ([]os.FileInfo, error) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
initCoreCommonFlags(serverCmd)
|
||||
initHugoBuilderFlags(serverCmd)
|
||||
|
||||
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
|
||||
serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
|
||||
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", true, "watch filesystem for changes and recreate as needed")
|
||||
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseurl")
|
||||
serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
|
||||
serverCmd.Flags().BoolVar(&renderToDisk, "renderToDisk", false, "render to Destination path (default is render to memory & serve from there)")
|
||||
serverCmd.Flags().BoolVarP(&NoTimes, "noTimes", "", false, "Don't sync modification time of files")
|
||||
serverCmd.Flags().String("memstats", "", "log memory usage to this file")
|
||||
serverCmd.Flags().Int("meminterval", 100, "interval to poll memory usage (requires --memstats)")
|
||||
serverCmd.RunE = server
|
||||
|
@ -148,10 +150,6 @@ func server(cmd *cobra.Command, args []string) error {
|
|||
viper.Set("PublishDir", "/")
|
||||
}
|
||||
|
||||
if serverCmd.Flags().Lookup("noTimes").Changed {
|
||||
viper.Set("NoTimes", NoTimes)
|
||||
}
|
||||
|
||||
if err := build(serverWatch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue