| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- // A simple TUI application that charts latency times to specified hosts.
- //
- // TODO(main): determine chart heights dynamically by number of addresses
- //
- // TODO(performance): implement ping message channel buffering
- //
- // i.e, change the address title to red so long as there is a single -1 in
- // the display buffer, and a toast notification (???) if a display buffer is
- // entirely composed of -1
- package main
- import (
- "flag"
- "fmt"
- "os"
- "pingo"
- "time"
- tea "charm.land/bubbletea/v2"
- )
- func main() {
- speed := flag.Int("s", 80, "the speed with which the UI runs")
- chartHeight := flag.Int("h", 0,
- "the height of the latency chart. set to 0 to render charts full screen.")
- flag.Parse()
- hosts := flag.Args()
- if len(hosts) == 0 {
- fmt.Println("Must specify hosts!")
- return
- }
- var model = pingo.InitialModel(
- hosts, time.Duration(*speed), *chartHeight,
- )
- p := tea.NewProgram(model) // tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
- // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
- if _, err := p.Run(); err != nil {
- fmt.Printf("Alas, there's been an error: %v", err)
- os.Exit(1)
- }
- }
|