1
0

pingo.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // A simple TUI application that charts latency times to specified hosts.
  2. //
  3. // i.e, change the address title to red so long as there is a single -1 in
  4. // the display buffer, and a toast notification (???) if a display buffer is
  5. // entirely composed of -1
  6. package main
  7. import (
  8. "flag"
  9. "fmt"
  10. "os"
  11. "pingo"
  12. "time"
  13. tea "charm.land/bubbletea/v2"
  14. )
  15. func main() {
  16. speed := flag.Int("s", 80, "the speed with which the UI runs")
  17. chartHeight := flag.Int("h", 0,
  18. "the height of the latency chart. set to 0 to render charts full screen.")
  19. flag.Parse()
  20. hosts := flag.Args()
  21. if len(hosts) == 0 {
  22. fmt.Println("Must specify hosts!")
  23. return
  24. }
  25. var model = pingo.InitialModel(
  26. hosts, time.Duration(*speed), *chartHeight,
  27. )
  28. p := tea.NewProgram(model) // tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  29. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  30. if _, err := p.Run(); err != nil {
  31. fmt.Printf("Alas, there's been an error: %v", err)
  32. os.Exit(1)
  33. }
  34. }