File: command_win.go

package info (click to toggle)
golang-github-spf13-cobra 0.0~git20161229.0.1dd5ff2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch, stretch-backports
  • size: 420 kB
  • ctags: 407
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 482 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// +build windows

package cobra

import (
	"os"
	"time"

	"github.com/inconshreveable/mousetrap"
)

var preExecHookFn = preExecHook

// enables an information splash screen on Windows if the CLI is started from explorer.exe.
var MousetrapHelpText string = `This is a command line tool

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)
	}
}