-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (49 loc) · 1.17 KB
/
main.go
File metadata and controls
58 lines (49 loc) · 1.17 KB
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
52
53
54
55
56
57
58
package main
import (
"flag"
"fmt"
"go-touch/internal/config"
"go-touch/internal/sources"
"go-touch/internal/types"
"go-touch/internal/ui"
"log"
)
func getText(cfg types.Config) (string, sources.TextSource, error) {
textSource, err := sources.NewTextSource(cfg.Text.Source, cfg.Text)
if err != nil {
return "", nil, err
}
text, err := textSource.GetText()
return text, textSource, err
}
func main() {
// Parse command-line flags
configPath := flag.String("config", "", "Path to config file")
flag.Parse()
// Load or create config
cfg, cfgPath, err := config.LoadOrCreateConfig(*configPath)
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
if cfgPath != "" {
fmt.Printf("Using config: %s\n", cfgPath)
}
// Ensure data directory exists for stats
dataDir, err := config.GetDataDir()
if err == nil {
config.EnsureDir(dataDir)
}
text, textSource, err := getText(*cfg)
if err != nil {
log.Fatal(err)
}
// Debug: Check if we got text
if text == "" {
log.Fatal("Error: No text generated")
}
sessionResult := ui.Run(*cfg, text, textSource)
if sessionResult.Error != nil {
log.Fatal(sessionResult.Error)
}
fmt.Println(sessionResult)
}