oh-my-posh/src/cli/debug.go

57 lines
1.2 KiB
Go
Raw Normal View History

2022-03-15 12:02:46 -07:00
package cli
import (
"fmt"
"oh-my-posh/color"
"oh-my-posh/console"
"oh-my-posh/engine"
"oh-my-posh/environment"
2022-03-21 23:41:36 -07:00
"oh-my-posh/shell"
2022-03-15 12:02:46 -07:00
"github.com/spf13/cobra"
)
// debugCmd represents the prompt command
var debugCmd = &cobra.Command{
Use: "debug",
Short: "Print the prompt in debug mode",
Long: "Print the prompt in debug mode.",
2022-03-15 12:02:46 -07:00
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
env := &environment.ShellEnvironment{
CmdFlags: &environment.Flags{
Config: config,
},
}
env.Init(true)
defer env.Close()
cfg := engine.LoadConfig(env)
ansi := &color.Ansi{}
ansi.InitPlain(shell.PLAIN)
2022-03-15 12:02:46 -07:00
writerColors := cfg.MakeColors(env)
writer := &color.AnsiWriter{
Ansi: ansi,
2022-03-21 23:41:36 -07:00
TerminalBackground: shell.ConsoleBackgroundColor(env, cfg.TerminalBackground),
2022-03-15 12:02:46 -07:00
AnsiColors: writerColors,
}
consoleTitle := &console.Title{
Env: env,
Ansi: ansi,
Template: cfg.ConsoleTitleTemplate,
}
eng := &engine.Engine{
Config: cfg,
Env: env,
Writer: writer,
ConsoleTitle: consoleTitle,
Ansi: ansi,
Plain: plain,
}
fmt.Print(eng.PrintDebug(cliVersion))
},
}
func init() { // nolint:gochecknoinits
2022-03-25 11:03:37 -07:00
rootCmd.AddCommand(debugCmd)
2022-03-15 12:02:46 -07:00
}