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

View file

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