-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (39 loc) · 782 Bytes
/
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
package main
import (
"flag"
"fmt"
"log"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/zan-preston/charm-ban/ui"
)
func createModel(debug bool) (ui.Model, *os.File) {
var loggerFile *os.File
var err error
if debug {
loggerFile, err = tea.LogToFile("debug.log", "debug")
if err != nil {
fmt.Println("Error setting up logger")
}
}
return ui.NewModel(), loggerFile
}
func main() {
debug := flag.Bool(
"debug",
false,
"passing this flag will allow writing debug output to debug.log",
)
flag.Parse()
model, logger := createModel(*debug)
if logger != nil {
defer logger.Close()
}
p := tea.NewProgram(
model,
tea.WithAltScreen(),
)
if err := p.Start(); err != nil {
log.Fatal(err)
}
}