-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (36 loc) · 914 Bytes
/
Copy pathmain.go
File metadata and controls
44 lines (36 loc) · 914 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
package main
import (
"fmt"
"os"
"runtime/debug"
tea "github.com/charmbracelet/bubbletea"
"golang.design/x/clipboard"
)
var Version string
func init() {
if Version == "" {
if info, ok := debug.ReadBuildInfo(); ok {
Version = info.Main.Version
}
}
if Version == "" {
Version = "dev"
}
}
func main() {
// Initialize clipboard
if err := clipboard.Init(); err != nil {
fmt.Fprintf(os.Stderr, "Error: failed to initialize clipboard: %v\n", err)
os.Exit(1)
}
handler := NewHandler()
handler.AddAction("Trim", "Remove leading and trailing whitespace", Trim)
handler.AddAction("Capitalize", "Capitalize words if text is fully uppercase", CapitalizeUppercase)
// Listen to clipboard changes in the background
go handler.Listen()
p := tea.NewProgram(NewUIModel(handler))
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error running cliptr: %v\n", err)
os.Exit(1)
}
}