From 9e73b15a3b8f5bc9a7237d272c1c075972c7f160 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Thu, 25 Jul 2024 13:11:29 +0200 Subject: [PATCH] feat(debug): provide shell name on debug --- src/cli/debug.go | 18 ++++++++++++------ src/cli/init.go | 29 ++++++++++++++++------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/cli/debug.go b/src/cli/debug.go index bbf07354..85789484 100644 --- a/src/cli/debug.go +++ b/src/cli/debug.go @@ -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, }, } diff --git a/src/cli/init.go b/src/cli/init.go index 30091533..ac222038 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -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()