feat(debug): provide shell name on debug

This commit is contained in:
Jan De Dobbeleer 2024-07-25 13:11:29 +02:00 committed by Jan De Dobbeleer
parent ffd961fc6c
commit 9e73b15a3b
2 changed files with 28 additions and 19 deletions

View file

@ -16,19 +16,25 @@ import (
// 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.",
Args: cobra.NoArgs,
Run: func(_ *cobra.Command, _ []string) {
Use: "debug [bash|zsh|fish|powershell|pwsh|cmd|nu|tcsh|elvish|xonsh]",
Short: "Print the prompt in debug mode",
Long: "Print the prompt in debug mode.",
ValidArgs: supportedShells,
Args: NoArgsOrOneValidArg,
Run: func(cmd *cobra.Command, args []string) {
startTime := time.Now()
if len(args) == 0 {
_ = cmd.Help()
return
}
env := &runtime.Terminal{
CmdFlags: &runtime.Flags{
Config: configFlag,
Debug: true,
PWD: pwd,
Shell: shellName,
Shell: args[0],
Plain: plain,
},
}

View file

@ -15,6 +15,20 @@ var (
printOutput bool
strict bool
manual bool
debug bool
supportedShells = []string{
"bash",
"zsh",
"fish",
"powershell",
"pwsh",
"cmd",
"nu",
"tcsh",
"elvish",
"xonsh",
}
initCmd = &cobra.Command{
Use: "init [bash|zsh|fish|powershell|pwsh|cmd|nu|tcsh|elvish|xonsh]",
@ -22,19 +36,8 @@ var (
Long: `Initialize your shell and config.
See the documentation to initialize your shell: https://ohmyposh.dev/docs/installation/prompt.`,
ValidArgs: []string{
"bash",
"zsh",
"fish",
"powershell",
"pwsh",
"cmd",
"nu",
"tcsh",
"elvish",
"xonsh",
},
Args: NoArgsOrOneValidArg,
ValidArgs: supportedShells,
Args: NoArgsOrOneValidArg,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()