|
|
@@ -19,6 +19,7 @@ import (
|
|
|
|
|
|
type md struct {
|
|
|
viewport viewport.Model
|
|
|
+ speed time.Duration
|
|
|
p pingo.Model
|
|
|
}
|
|
|
|
|
|
@@ -39,7 +40,7 @@ var (
|
|
|
)
|
|
|
|
|
|
func (m md) Init() tea.Cmd {
|
|
|
- return tea.Tick(100*time.Millisecond, func(t time.Time) tea.Msg { return timingMsg(t) })
|
|
|
+ return tea.Tick(m.speed*time.Millisecond, func(t time.Time) tea.Msg { return timingMsg(t) })
|
|
|
}
|
|
|
|
|
|
func (m md) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
|
@@ -65,8 +66,8 @@ func (m md) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
|
return m, tea.Quit
|
|
|
}
|
|
|
case timingMsg:
|
|
|
- cmd = tea.Tick(100*time.Millisecond, func(t time.Time) tea.Msg { return timingMsg(t) })
|
|
|
- cmds = append(cmds, cmd, m.p.Poll())
|
|
|
+ cmd = tea.Tick(m.speed*time.Millisecond, func(t time.Time) tea.Msg { return timingMsg(t) })
|
|
|
+ cmds = append(cmds, tea.Sequence(m.p.Poll(), cmd))
|
|
|
}
|
|
|
|
|
|
m.viewport.SetContent(m.p.View().Content)
|
|
|
@@ -99,7 +100,7 @@ func (m md) footer() string {
|
|
|
func (m md) getVerticalMargin() int { return lipgloss.Height(m.header() + m.footer()) }
|
|
|
|
|
|
func main() {
|
|
|
- // speed := flag.Int("s", 80, "the speed with which the UI runs")
|
|
|
+ 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()
|
|
|
@@ -110,7 +111,7 @@ func main() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- p := tea.NewProgram(md{p: pingo.InitialModel(hosts, 20, 10, *chartHeight)})
|
|
|
+ p := tea.NewProgram(md{p: pingo.InitialModel(hosts, 20, 10, *chartHeight), speed: time.Duration(*speed)})
|
|
|
|
|
|
if _, err := p.Run(); err != nil {
|
|
|
fmt.Printf("Alas, there's been an error: %v", err)
|