fix(cli): initialize .Var correctly

This commit is contained in:
Jan De Dobbeleer 2024-02-14 21:34:59 +01:00 committed by Jan De Dobbeleer
parent 344376f8eb
commit 43e9246c6b
2 changed files with 13 additions and 1 deletions

View file

@ -57,10 +57,13 @@ Exports the config to an image file using customized output options.`,
defer env.Close()
cfg := engine.LoadConfig(env)
// set dsane defaults for things we don't print
// set sane defaults for things we don't print
cfg.ConsoleTitleTemplate = ""
cfg.PWD = ""
// add variables to the environment
env.Var = cfg.Var
writerColors := cfg.MakeColors()
writer := &ansi.Writer{
TerminalBackground: shell.ConsoleBackgroundColor(env, cfg.TerminalBackground),

View file

@ -21,6 +21,7 @@ var debugCmd = &cobra.Command{
Args: cobra.NoArgs,
Run: func(_ *cobra.Command, _ []string) {
startTime := time.Now()
env := &platform.Shell{
CmdFlags: &platform.Flags{
Config: config,
@ -30,9 +31,15 @@ var debugCmd = &cobra.Command{
Plain: plain,
},
}
env.Init()
defer env.Close()
cfg := engine.LoadConfig(env)
// add variables to the environment
env.Var = cfg.Var
writerColors := cfg.MakeColors()
writer := &ansi.Writer{
TerminalBackground: shell.ConsoleBackgroundColor(env, cfg.TerminalBackground),
@ -40,6 +47,7 @@ var debugCmd = &cobra.Command{
Plain: plain,
TrueColor: env.CmdFlags.TrueColor,
}
writer.Init(shell.GENERIC)
eng := &engine.Engine{
Config: cfg,
@ -47,6 +55,7 @@ var debugCmd = &cobra.Command{
Writer: writer,
Plain: plain,
}
fmt.Print(eng.PrintDebug(startTime, build.Version))
},
}