command_win.go 482 B

1234567891011121314151617181920212223242526
  1. // +build windows
  2. package cobra
  3. import (
  4. "os"
  5. "time"
  6. "github.com/inconshreveable/mousetrap"
  7. )
  8. var preExecHookFn = preExecHook
  9. // enables an information splash screen on Windows if the CLI is started from explorer.exe.
  10. var MousetrapHelpText string = `This is a command line tool
  11. You need to open cmd.exe and run it from there.
  12. `
  13. func preExecHook(c *Command) {
  14. if mousetrap.StartedByExplorer() {
  15. c.Print(MousetrapHelpText)
  16. time.Sleep(5 * time.Second)
  17. os.Exit(1)
  18. }
  19. }