1// +build windows 2 3package cobra 4 5import ( 6 "os" 7 "time" 8 9 "github.com/inconshreveable/mousetrap" 10) 11 12var preExecHookFn = preExecHook 13 14// enables an information splash screen on Windows if the CLI is started from explorer.exe. 15var MousetrapHelpText string = `This is a command line tool 16 17You need to open cmd.exe and run it from there. 18` 19 20func preExecHook(c *Command) { 21 if mousetrap.StartedByExplorer() { 22 c.Print(MousetrapHelpText) 23 time.Sleep(5 * time.Second) 24 os.Exit(1) 25 } 26} 27