command_win.go

 1// +build windows
 2
 3package cobra
 4
 5import (
 6	"fmt"
 7	"os"
 8	"time"
 9
10	"github.com/inconshreveable/mousetrap"
11)
12
13var preExecHookFn = preExecHook
14
15func preExecHook(c *Command) {
16	if MousetrapHelpText != "" && mousetrap.StartedByExplorer() {
17		c.Print(MousetrapHelpText)
18		if MousetrapDisplayDuration > 0 {
19			time.Sleep(MousetrapDisplayDuration)
20		} else {
21			c.Println("Press return to continue...")
22			fmt.Scanln()
23		}
24		os.Exit(1)
25	}
26}