forked from charmbracelet/gum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (50 loc) · 1.27 KB
/
main.go
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 (
"fmt"
"runtime/debug"
"github.com/alecthomas/kong"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
)
var (
// Version contains the application version number. It's set via ldflags
// when building.
Version = ""
// CommitSHA contains the SHA of the commit that this application was built
// against. It's set via ldflags when building.
CommitSHA = ""
)
var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
func main() {
lipgloss.SetColorProfile(termenv.ANSI256)
if Version == "" {
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
Version = info.Main.Version
} else {
Version = "unknown (built from source)"
}
}
version := fmt.Sprintf("gum version %s", Version)
if len(CommitSHA) >= 7 {
version += " (" + CommitSHA[:7] + ")"
}
gum := &Gum{}
ctx := kong.Parse(
gum,
kong.Description(fmt.Sprintf("Tasty bubble %s for your shell.", bubbleGumPink.Render("gum"))),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: false,
}),
kong.Vars{
"version": version,
"defaultBackground": "",
"defaultForeground": "",
"defaultMargin": "0 0",
"defaultPadding": "0 0",
"defaultUnderline": "false",
},
)
ctx.Run()
}