util.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package util
  2. import "fmt"
  3. // TarBin describes the default installation point of tar command.
  4. const TarBin string = "/usr/bin/tar"
  5. // MakepkgBin describes the default installation point of makepkg command.
  6. const MakepkgBin string = "/usr/bin/makepkg"
  7. // SearchVerbosity determines print method used in PrintSearch
  8. var SearchVerbosity = NumberMenu
  9. // Verbosity settings for search
  10. const (
  11. NumberMenu = iota
  12. Detailed
  13. Minimal
  14. )
  15. // NoConfirm ignores prompts.
  16. var NoConfirm = false
  17. // SortMode determines top down package or down top package display
  18. var SortMode = BottomUp
  19. // BaseDir is the default building directory for yay
  20. var BaseDir = "/tmp/yaytmp/"
  21. // Describes Sorting method for numberdisplay
  22. const (
  23. BottomUp = iota
  24. TopDown
  25. )
  26. // ContinueTask prompts if user wants to continue task.
  27. //If NoConfirm is set the action will continue without user input.
  28. func ContinueTask(s string, def string) (cont bool) {
  29. if NoConfirm {
  30. return true
  31. }
  32. var postFix string
  33. if def == "nN" {
  34. postFix = "(Y/n)"
  35. } else {
  36. postFix = "(y/N)"
  37. }
  38. var response string
  39. fmt.Printf("\x1b[1;32m==> %s\x1b[1;37m %s\x1b[0m\n", s, postFix)
  40. fmt.Scanln(&response)
  41. if response == string(def[0]) || response == string(def[1]) {
  42. return false
  43. }
  44. return true
  45. }