ref: 8a5124d6b38156cb6f765ac7492513ac7c0d90b2
parent: 898a0a96afd472fad8fe70be71f6cb00a4267c4a
author: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com>
date: Wed Feb 12 19:37:49 EST 2020
commands: Rename doWithCommandeer to cfgInit/cfgSetAndInit This will make it clearer what it does and make the code more consistent.
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -72,7 +72,7 @@
visitedURLs *types.EvictingStringQueue
- doWithCommandeer func(c *commandeer) error
+ cfgInit func(c *commandeer) error
// We watch these for changes.
configFiles []string
@@ -152,7 +152,7 @@
return nil
}
-func newCommandeer(mustHaveConfigFile, running bool, h *hugoBuilderCommon, f flagsToConfigHandler, doWithCommandeer func(c *commandeer) error, subCmdVs ...*cobra.Command) (*commandeer, error) {
+func newCommandeer(mustHaveConfigFile, running bool, h *hugoBuilderCommon, f flagsToConfigHandler, cfgInit func(c *commandeer) error, subCmdVs ...*cobra.Command) (*commandeer, error) {
var rebuildDebouncer func(f func())
if running {
@@ -171,7 +171,7 @@
h: h,
ftch: f,
commandeerHugoState: newCommandeerHugoState(),
- doWithCommandeer: doWithCommandeer,
+ cfgInit: cfgInit,
visitedURLs: types.NewEvictingStringQueue(10),
debounce: rebuildDebouncer,
fullRebuildSem: semaphore.NewWeighted(1),
@@ -284,12 +284,12 @@
return nil
}
- doWithCommandeer := func(cfg config.Provider) error {
+ cfgSetAndInit := func(cfg config.Provider) error {
c.Cfg = cfg
- if c.doWithCommandeer == nil {
+ if c.cfgInit == nil {
return nil
}
- err := c.doWithCommandeer(c)
+ err := c.cfgInit(c)
return err
}
@@ -307,7 +307,7 @@
AbsConfigDir: c.h.getConfigDir(dir),
Environ: os.Environ(),
Environment: environment},
- doWithCommandeer,
+ cfgSetAndInit,
doWithConfig)
if err != nil && mustHaveConfigFile {
@@ -330,8 +330,8 @@
// This is potentially double work, but we need to do this one more time now
// that all the languages have been configured.
- if c.doWithCommandeer != nil {
- if err := c.doWithCommandeer(c); err != nil {
+ if c.cfgInit != nil {
+ if err := c.cfgInit(c); err != nil {
return err
}
}
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -118,9 +118,9 @@
func initializeConfig(mustHaveConfigFile, running bool,
h *hugoBuilderCommon,
f flagsToConfigHandler,
- doWithCommandeer func(c *commandeer) error) (*commandeer, error) {
+ cfgInit func(c *commandeer) error) (*commandeer, error) {
- c, err := newCommandeer(mustHaveConfigFile, running, h, f, doWithCommandeer)
+ c, err := newCommandeer(mustHaveConfigFile, running, h, f, cfgInit)
if err != nil {
return nil, err
}