gum/main.go

59 lines
1.3 KiB
Go
Raw Normal View History

2022-06-11 00:07:40 +02:00
package main
import (
"fmt"
2022-07-28 20:10:43 +02:00
"runtime/debug"
2022-06-11 00:07:40 +02:00
"github.com/alecthomas/kong"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
2022-06-11 00:07:40 +02:00
)
2022-07-28 20:10:43 +02:00
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"))
2022-06-11 00:07:40 +02:00
func main() {
lipgloss.SetColorProfile(termenv.ANSI256)
2022-07-28 20:10:43 +02:00
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] + ")"
}
2022-07-07 19:26:35 +02:00
gum := &Gum{}
ctx := kong.Parse(
gum,
kong.Description(fmt.Sprintf("Tasty bubble %s for your shell.", bubbleGumPink.Render("gum"))),
2022-06-11 00:07:40 +02:00
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: false,
}),
kong.Vars{
2022-07-28 20:10:43 +02:00
"version": version,
"defaultBackground": "",
"defaultForeground": "",
2022-07-26 21:43:26 +02:00
"defaultMargin": "0 0",
"defaultPadding": "0 0",
"defaultUnderline": "false",
},
)
_ = ctx.Run()
2022-06-11 00:07:40 +02:00
}