diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-04-20 11:05:35 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-04-20 15:09:12 +0200 |
commit | 004b6943906471cff0d0232040d24cff6cb89e6b (patch) | |
tree | 75d2492a0553a283c16a26cb5df9a178c5baa5ec /commands/commandeer.go | |
parent | da6112fc65346d0f4e12b52d0580258cf02716c9 (diff) |
Fix partial rebuilds for SCSS fetched with GetMatch and similar
Fixes #12395
Diffstat (limited to 'commands/commandeer.go')
-rw-r--r-- | commands/commandeer.go | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index f18c3f813..616a3c867 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -128,6 +128,7 @@ type rootCommand struct { verbose bool debug bool quiet bool + devMode bool // Hidden flag. renderToMemory bool @@ -423,29 +424,33 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error { func (r *rootCommand) createLogger(running bool) (loggers.Logger, error) { level := logg.LevelWarn - if r.logLevel != "" { - switch strings.ToLower(r.logLevel) { - case "debug": - level = logg.LevelDebug - case "info": - level = logg.LevelInfo - case "warn", "warning": - level = logg.LevelWarn - case "error": - level = logg.LevelError - default: - return nil, fmt.Errorf("invalid log level: %q, must be one of debug, warn, info or error", r.logLevel) - } + if r.devMode { + level = logg.LevelTrace } else { - if r.verbose { - hugo.Deprecate("--verbose", "use --logLevel info", "v0.114.0") - hugo.Deprecate("--verbose", "use --logLevel info", "v0.114.0") - level = logg.LevelInfo - } + if r.logLevel != "" { + switch strings.ToLower(r.logLevel) { + case "debug": + level = logg.LevelDebug + case "info": + level = logg.LevelInfo + case "warn", "warning": + level = logg.LevelWarn + case "error": + level = logg.LevelError + default: + return nil, fmt.Errorf("invalid log level: %q, must be one of debug, warn, info or error", r.logLevel) + } + } else { + if r.verbose { + hugo.Deprecate("--verbose", "use --logLevel info", "v0.114.0") + hugo.Deprecate("--verbose", "use --logLevel info", "v0.114.0") + level = logg.LevelInfo + } - if r.debug { - hugo.Deprecate("--debug", "use --logLevel debug", "v0.114.0") - level = logg.LevelDebug + if r.debug { + hugo.Deprecate("--debug", "use --logLevel debug", "v0.114.0") + level = logg.LevelDebug + } } } @@ -505,10 +510,13 @@ Complete documentation is available at https://gohugo.io/.` cmd.PersistentFlags().BoolVarP(&r.verbose, "verbose", "v", false, "verbose output") cmd.PersistentFlags().BoolVarP(&r.debug, "debug", "", false, "debug output") + cmd.PersistentFlags().BoolVarP(&r.devMode, "devMode", "", false, "only used for internal testing, flag hidden.") cmd.PersistentFlags().StringVar(&r.logLevel, "logLevel", "", "log level (debug|info|warn|error)") _ = cmd.RegisterFlagCompletionFunc("logLevel", cobra.FixedCompletions([]string{"debug", "info", "warn", "error"}, cobra.ShellCompDirectiveNoFileComp)) cmd.Flags().BoolVarP(&r.buildWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed") + cmd.PersistentFlags().MarkHidden("devMode") + // Configure local flags applyLocalFlagsBuild(cmd, r) |