main.go 781 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "os"
  6. "pingo/internal/tui"
  7. "time"
  8. tea "github.com/charmbracelet/bubbletea"
  9. )
  10. func main() {
  11. speed := flag.Int("s", 80, "the speed with which the UI runs")
  12. flag.Parse()
  13. hosts := flag.Args()
  14. if len(hosts) == 0 {
  15. fmt.Println("Must specify hosts!")
  16. return
  17. }
  18. var model = tui.InitialModel( // TODO(argv) set args via argv
  19. // []string{"doesntresolve.comdoasdf", "google.ca"},
  20. hosts, time.Duration(*speed),
  21. )
  22. p := tea.NewProgram(model,
  23. tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  24. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  25. )
  26. if _, err := p.Run(); err != nil {
  27. fmt.Printf("Alas, there's been an error: %v", err)
  28. os.Exit(1)
  29. }
  30. }