1
0

main.go 901 B

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