command_win.go
This file
Path
command_win.go
26 lines · 482 bytes · Go
Last changed by
Merge pull request #197 from magiconair/issue-195-mousetrap-win-onlyEric Parisbefore adoption7366561
History of this fileTake it
Merge pull request #197 from magiconair/issue-195-mousetrap-win-onlyEric Parisbefore adoption7366561
lines 1–26why, one step back1// +build windows23package cobra45import (6 "os"7 "time"89 "github.com/inconshreveable/mousetrap"10)1112var preExecHookFn = preExecHook1314// enables an information splash screen on Windows if the CLI is started from explorer.exe.15var MousetrapHelpText string = `This is a command line tool1617You need to open cmd.exe and run it from there.18`1920func preExecHook(c *Command) {21 if mousetrap.StartedByExplorer() {22 c.Print(MousetrapHelpText)23 time.Sleep(5 * time.Second)24 os.Exit(1)25 }26}