-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (36 loc) · 881 Bytes
/
Copy pathmain.go
File metadata and controls
45 lines (36 loc) · 881 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
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
// Set by GoReleaser via ldflags.
var version = "dev"
func main() {
// Handle --version
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
fmt.Printf("traverse %s\n", version)
os.Exit(0)
}
// Clean undo directory on exit
defer cleanUndoDir()
// Load configuration
cfg, err := LoadConfig()
if err != nil {
fmt.Fprintf(os.Stderr, "Warning: error loading config: %v\n", err)
cfg = DefaultConfig()
}
// Determine start directory
startDir := ""
if len(os.Args) > 1 {
startDir = os.Args[1]
}
// Create application
app := NewApp(cfg, startDir)
// Run with mouse support enabled
p := tea.NewProgram(app, tea.WithAltScreen(), tea.WithMouseAllMotion())
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}