Skip to content

Commit 51d0a0a

Browse files
committedMay 28, 2023
commands: Add the common build flags to the config commands
Which allows to see the config with `--theme` applied. Updates #11018
1 parent fd09933 commit 51d0a0a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎commands/commandeer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ func applyLocalFlagsBuildConfig(cmd *cobra.Command, r *rootCommand) {
520520
cmd.Flags().StringP("cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
521521
_ = cmd.Flags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
522522
cmd.Flags().StringP("contentDir", "c", "", "filesystem path to content directory")
523-
cmd.Flags().StringP("layoutDir", "l", "", "filesystem path to layout directory")
524523
_ = cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
525524

526525
}
@@ -534,6 +533,7 @@ func applyLocalFlagsBuild(cmd *cobra.Command, r *rootCommand) {
534533
cmd.Flags().BoolP("buildExpired", "E", false, "include expired content")
535534
cmd.Flags().BoolP("ignoreCache", "", false, "ignores the cache directory")
536535
cmd.Flags().Bool("enableGitInfo", false, "add Git revision, date, author, and CODEOWNERS info to the pages")
536+
cmd.Flags().StringP("layoutDir", "l", "", "filesystem path to layout directory")
537537
cmd.Flags().BoolVar(&r.gc, "gc", false, "enable to run some cleanup tasks (remove unused cache files) after the build")
538538
cmd.Flags().StringVar(&r.poll, "poll", "", "set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes")
539539
cmd.Flags().BoolVar(&r.panicOnWarning, "panicOnWarning", false, "panic on first WARNING log")

‎commands/config.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,17 @@ func (c *configCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg
9595
}
9696

9797
func (c *configCommand) Init(cd *simplecobra.Commandeer) error {
98+
c.r = cd.Root.Command.(*rootCommand)
9899
cmd := cd.CobraCommand
99100
cmd.Short = "Print the site configuration"
100101
cmd.Long = `Print the site configuration, both default and custom settings.`
101102
cmd.Flags().StringVar(&c.format, "format", "toml", "preferred file format (toml, yaml or json)")
103+
applyLocalFlagsBuildConfig(cmd, c.r)
102104

103105
return nil
104106
}
105107

106108
func (c *configCommand) PreRun(cd, runner *simplecobra.Commandeer) error {
107-
c.r = cd.Root.Command.(*rootCommand)
108109
return nil
109110
}
110111

@@ -179,6 +180,7 @@ func (m *configModMounts) MarshalJSON() ([]byte, error) {
179180
}
180181

181182
type configMountsCommand struct {
183+
r *rootCommand
182184
configCmd *configCommand
183185
}
184186

@@ -206,8 +208,10 @@ func (c *configMountsCommand) Run(ctx context.Context, cd *simplecobra.Commandee
206208
}
207209

208210
func (c *configMountsCommand) Init(cd *simplecobra.Commandeer) error {
211+
c.r = cd.Root.Command.(*rootCommand)
209212
cmd := cd.CobraCommand
210213
cmd.Short = "Print the configured file mounts"
214+
applyLocalFlagsBuildConfig(cmd, c.r)
211215
return nil
212216
}
213217

0 commit comments

Comments
 (0)
Please sign in to comment.