From a25becd5358d12431df0e832d7162dba9e7f48b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Ledesma?= Date: Tue, 17 Jan 2017 14:25:22 +0100 Subject: [PATCH] Add EnableWindowsMouseTrap variable again (removed in commit 193b182195dad17ec904d4851f33e3ee3696bf07) --- cobra.go | 3 +++ command_win.go | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) 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) + } } }