-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
51 lines (39 loc) · 1.19 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/KonstantinGasser/scotty/app"
"github.com/KonstantinGasser/scotty/store"
"github.com/KonstantinGasser/scotty/stream"
tea "github.com/charmbracelet/bubbletea"
)
var version = "dev"
func main() {
if len(os.Args) >= 2 && os.Args[1] == "version" {
fmt.Printf("scotty:\t%s\n", version)
return
}
network := flag.String("network", "unix", "network interface to listen for beams (option: tcp)")
addr := flag.String("addr", "/tmp/scotty.sock", "address for the network interface")
buffer := flag.Int("buffer", 4096, "buffer to store logs will hold up N items")
refresh := flag.Duration("refresh", time.Millisecond*50, "refresh rate of the pager. Can be increased if high through put is expected in order to reduce lags")
flag.Parse()
quite := make(chan struct{})
multiplex, err := stream.New(quite, *network, *addr)
if err != nil {
fmt.Println(err.Error())
return
}
go multiplex.Run()
lStore := store.New(uint32(*buffer))
ui := app.New(quite, *refresh, lStore, multiplex)
bubble := tea.NewProgram(ui,
tea.WithAltScreen(),
)
if _, err := bubble.Run(); err != nil {
fmt.Printf("unable to start scotty: %v", err)
return
}
}