2016-01-15 18:48:03 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package cobra
|
|
|
|
|
|
|
|
import (
|
2019-06-09 00:01:48 +00:00
|
|
|
"fmt"
|
2016-01-15 18:48:03 +00:00
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
2016-01-15 18:53:01 +00:00
|
|
|
"github.com/inconshreveable/mousetrap"
|
2016-01-15 18:48:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var preExecHookFn = preExecHook
|
|
|
|
|
|
|
|
func preExecHook(c *Command) {
|
2018-05-04 21:39:27 +00:00
|
|
|
if MousetrapHelpText != "" && mousetrap.StartedByExplorer() {
|
2016-01-15 18:48:03 +00:00
|
|
|
c.Print(MousetrapHelpText)
|
2019-06-09 00:01:48 +00:00
|
|
|
if MousetrapDisplayDuration > 0 {
|
|
|
|
time.Sleep(MousetrapDisplayDuration)
|
|
|
|
} else {
|
|
|
|
c.Println("Press return to continue...")
|
|
|
|
fmt.Scanln()
|
|
|
|
}
|
2016-01-15 18:48:03 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|