diff --git a/cobra.go b/cobra.go index b39c715a..96fdb755 100644 --- a/cobra.go +++ b/cobra.go @@ -45,6 +45,9 @@ var EnablePrefixMatching = false // To disable sorting, set it to false. var EnableCommandSorting = true +// EnableWindowsMouseTrap enables an information splash screen on Windows if the CLI is started from explorer.exe. +var EnableWindowsMouseTrap = true + // AddTemplateFunc adds a template function that's available to Usage and Help // template generation. func AddTemplateFunc(name string, tmplFunc interface{}) { diff --git a/command_win.go b/command_win.go index 4b0eaa1b..3ef7aac1 100644 --- a/command_win.go +++ b/command_win.go @@ -18,9 +18,11 @@ You need to open cmd.exe and run it from there. ` func preExecHook(c *Command) { - if mousetrap.StartedByExplorer() { - c.Print(MousetrapHelpText) - time.Sleep(5 * time.Second) - os.Exit(1) + if EnableWindowsMouseTrap { + if mousetrap.StartedByExplorer() { + c.Print(MousetrapHelpText) + time.Sleep(5 * time.Second) + os.Exit(1) + } } }