-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (42 loc) · 991 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
50
51
package main
import (
"flag"
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/gunererd/grease/internal/editor"
"github.com/gunererd/grease/internal/filemanager"
)
func main() {
f, err := tea.LogToFile("debug.log", "DEBUG")
if err != nil {
fmt.Fprintf(os.Stderr, "Error setting up logging: %v\n", err)
os.Exit(1)
}
defer f.Close()
opts := editor.RegisterFlags()
flag.Parse()
e, err := editor.Initialize(*opts)
if err != nil {
fmt.Fprintf(os.Stderr, "Error initializing editor: %v\n", err)
os.Exit(1)
}
path := "."
if opts.Filename != "" {
path = opts.Filename
}
fm := filemanager.New(path, e)
if err := fm.LoadDirectory(); err != nil {
fmt.Fprintf(os.Stderr, "Error loading directory: %v\n", err)
os.Exit(1)
}
p := tea.NewProgram(fm,
tea.WithAltScreen(),
tea.WithMouseCellMotion(),
tea.WithMouseAllMotion(),
)
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error running program: %v\n", err)
os.Exit(1)
}
}