1
0

main.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // A simple TUI application that charts latency times to specified hosts.
  2. //
  3. // TODO(main): set chart height by user flag
  4. //
  5. // TODO(main): determine chart heights dynamically by number of addresses
  6. //
  7. // TODO(performance): implement ping message channel buffering
  8. //
  9. // TODO(tui): notify user when an address is not resolving
  10. //
  11. // i.e, change the address title to red so long as there is a single -1 in
  12. // the display buffer, and a toast notification (???) if a display buffer is
  13. // entirely composed of -1
  14. package main
  15. import (
  16. "flag"
  17. "fmt"
  18. "os"
  19. "pingo/internal/tui"
  20. "time"
  21. tea "github.com/charmbracelet/bubbletea"
  22. )
  23. func main() {
  24. speed := flag.Int("s", 80, "the speed with which the UI runs")
  25. flag.Parse()
  26. hosts := flag.Args()
  27. if len(hosts) == 0 {
  28. fmt.Println("Must specify hosts!")
  29. return
  30. }
  31. var model = tui.InitialModel(
  32. hosts, time.Duration(*speed),
  33. )
  34. p := tea.NewProgram(model,
  35. tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  36. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  37. )
  38. if _, err := p.Run(); err != nil {
  39. fmt.Printf("Alas, there's been an error: %v", err)
  40. os.Exit(1)
  41. }
  42. }