-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (35 loc) · 916 Bytes
/
main.go
File metadata and controls
42 lines (35 loc) · 916 Bytes
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
package main
import (
"fmt"
"os"
"github.com/jroimartin/gocui"
"github.com/myuron/graftx/internal/fs"
"github.com/myuron/graftx/internal/selector"
"github.com/myuron/graftx/internal/ui"
)
func main() {
cwd, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "failed to get current directory: %v\n", err)
os.Exit(1)
}
app, err := ui.NewApp(cwd, &fs.OSFS{}, &selector.DefaultRunner{})
if err != nil {
fmt.Fprintf(os.Stderr, "failed to initialize application: %v\n", err)
os.Exit(1)
}
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to initialize GUI: %v\n", err)
os.Exit(1)
}
defer g.Close()
if err := app.SetGui(g); err != nil {
fmt.Fprintf(os.Stderr, "failed to configure GUI: %v\n", err)
os.Exit(1)
}
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}