-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (37 loc) · 1.06 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
package main
import (
"fmt"
"os"
"path/filepath"
tea "github.com/charmbracelet/bubbletea"
"github.com/gabrielfu/agora/internal"
"github.com/gabrielfu/agora/tui"
)
func Run() error {
var collectionStore *internal.CollectionStore
var err error
if len(os.Args) > 1 {
rootDir := filepath.Join(os.Args[1], ".agora")
collectionStore, err = internal.NewCollectionStore(rootDir)
} else {
collectionStore, err = internal.NewDefaultCollectionStore()
}
if err != nil {
return fmt.Errorf("error initializing collection store: %v", err)
}
collectionRequestDir := collectionStore.CurrentCollectionRequestDir()
requestStore, err := internal.NewRequestFileStore(collectionRequestDir)
if err != nil {
return fmt.Errorf("error initializing collection store: %v", err)
}
model := tui.NewRootModel(collectionStore, requestStore, tui.WithCollectionPaneWidth(0.33))
program := tea.NewProgram(model, tea.WithAltScreen(), tea.WithMouseCellMotion())
_, err = program.Run()
return err
}
func main() {
if err := Run(); err != nil {
fmt.Printf("%v\n", err)
os.Exit(1)
}
}