initial commit

This commit is contained in:
Karol Broda
2025-12-16 22:42:49 +01:00
commit 371f4d13a6
61 changed files with 6872 additions and 0 deletions

35
internal/tui/messages.go Normal file
View File

@@ -0,0 +1,35 @@
package tui
import (
"snitch/internal/collector"
"time"
tea "github.com/charmbracelet/bubbletea"
)
type tickMsg time.Time
type dataMsg struct {
connections []collector.Connection
}
type errMsg struct {
err error
}
func (m model) tick() tea.Cmd {
return tea.Tick(m.interval, func(t time.Time) tea.Msg {
return tickMsg(t)
})
}
func (m model) fetchData() tea.Cmd {
return func() tea.Msg {
conns, err := collector.GetConnections()
if err != nil {
return errMsg{err}
}
return dataMsg{connections: conns}
}
}