Issue #195: Compile mousetrap only on Windows
* Create command_win.go and command_notwin.go for windows only code * Move call to mousetrap hook into separate preExecHook() function
This commit is contained in:
12
command.go
12
command.go
@ -21,11 +21,8 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/inconshreveable/mousetrap"
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
@ -626,12 +623,9 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||
return c.Root().ExecuteC()
|
||||
}
|
||||
|
||||
if EnableWindowsMouseTrap && runtime.GOOS == "windows" {
|
||||
if mousetrap.StartedByExplorer() {
|
||||
c.Print(MousetrapHelpText)
|
||||
time.Sleep(5 * time.Second)
|
||||
os.Exit(1)
|
||||
}
|
||||
// windows hook
|
||||
if preExecHookFn != nil {
|
||||
preExecHookFn(c)
|
||||
}
|
||||
|
||||
// initialize help as the last point possible to allow for user
|
||||
|
Reference in New Issue
Block a user