command_win.go 433 B

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