-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (39 loc) · 1023 Bytes
/
main.go
File metadata and controls
49 lines (39 loc) · 1023 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
43
44
45
46
47
48
49
package main
import (
"context"
"fmt"
"os"
"dazzle/internal/application"
"dazzle/internal/infrastructure/openapi"
"dazzle/internal/ui"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
func run() error {
if len(os.Args) != 2 {
fmt.Println("dazzle — spec-aware API explorer")
fmt.Println()
fmt.Println("Usage: dazzle <spec-file-or-url>")
return fmt.Errorf("expected exactly one argument")
}
source := os.Args[1]
if f := os.Getenv("DAZZLE_DEBUG"); f != "" {
logFile, err := tea.LogToFile(f, "dazzle")
if err != nil {
return fmt.Errorf("debug log: %w", err)
}
defer logFile.Close()
}
repo := openapi.NewRepository()
specSvc := application.NewSpecService(repo)
opSvc := application.NewOperationService()
app := ui.NewAppModel(context.Background(), specSvc, opSvc, source)
p := tea.NewProgram(app, tea.WithAltScreen(), tea.WithMouseCellMotion())
_, err := p.Run()
return err
}