-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (48 loc) · 1.13 KB
/
Copy pathmain.go
File metadata and controls
57 lines (48 loc) · 1.13 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
// Package main is the entry point for the vanish program
package main
import (
"fmt"
"log"
"os"
tea "github.com/charmbracelet/bubbletea"
"vanish/cmd/commands"
"vanish/internal/config"
"vanish/internal/tui"
)
func main() {
cfg, err := config.LoadConfig()
if err != nil {
log.Fatalf("Error loading config: %v", err)
}
args := os.Args[1:]
if len(args) == 0 {
command.ShowUsage(cfg)
return
}
parsed := command.ParseArgs(args, cfg)
// Validate
if parsed.Operation == "" || len(parsed.Filenames) == 0 {
if parsed.Operation != "clear" {
command.ShowUsage(cfg)
os.Exit(1)
}
}
// Check if headless mode is enabled
if parsed.Headless {
// Run without TUI
if err := tui.ExecuteHeadless(parsed.Filenames, parsed.Operation, cfg); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
return
}
// Initialize and run TUI (normal mode)
m, err := tui.InitialModel(parsed.Filenames, parsed.Operation, parsed.NoConfirm)
if err != nil {
log.Fatalf("Error initializing: %v", err)
}
p := tea.NewProgram(m)
if _, err := p.Run(); err != nil {
log.Fatalf("Error running program: %v", err)
}
}