Something went wrong. Try again.
bluesky viewer in the terminal
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106package ui
import ( "io" "strings"
"github.com/charmbracelet/lipgloss" "github.com/urfave/cli/v3")
// styleSectionHeader applies accent color to section headers (NAME:, USAGE:, etc.)func styleSectionHeader(s string) string { if strings.HasSuffix(s, ":") { return AccentStyle.Bold(true).Render(s) } return s}
// styleCommandName applies primary color to command namesfunc styleCommandName(s string) string { return PrimaryStyle.Render(s)}
// styleDim applies dim styling to descriptionsfunc styleDim(s string) string { return lipgloss.NewStyle().Faint(true).Render(s)}
// StyledHelpPrinter is a custom help printer that uses our color system// It extends the default printer with custom styling functionsfunc StyledHelpPrinter(w io.Writer, templ string, data any) { customFuncs := map[string]any{ "styleHeader": styleSectionHeader, "styleCommand": styleCommandName, "styleDim": styleDim, "styleAccent": func(s string) string { return AccentStyle.Render(s) }, "stylePrimary": func(s string) string { return PrimaryStyle.Render(s) }, }
cli.DefaultPrintHelpCustom(w, templ, data, customFuncs)}
// RootCommandHelpTemplate uses the default template structure with styling functionsconst RootCommandHelpTemplate = `{{styleHeader "NAME:"}} {{template "helpNameTemplate" .}}
{{styleHeader "USAGE:"}} {{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.FullName}} {{if .VisibleFlags}}[global options]{{end}}{{if .VisibleCommands}} [command [command options]]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Arguments}} [arguments...]{{end}}{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
{{styleHeader "VERSION:"}} {{stylePrimary .Version}}{{end}}{{end}}{{if .Description}}
{{styleHeader "DESCRIPTION:"}} {{template "descriptionTemplate" .}}{{end}}{{- if len .Authors}}
{{styleHeader "AUTHOR"}}{{template "authorsTemplate" .}}{{end}}{{if .VisibleCommands}}
{{styleHeader "COMMANDS:"}}{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
{{styleHeader "GLOBAL OPTIONS:"}}{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}}
{{styleHeader "GLOBAL OPTIONS:"}}{{template "visibleFlagTemplate" .}}{{end}}{{if .Copyright}}
{{styleHeader "COPYRIGHT:"}} {{template "copyrightTemplate" .}}{{end}}`
// CommandHelpTemplate uses the default template structure with stylingconst CommandHelpTemplate = `{{styleHeader "NAME:"}} {{template "helpNameTemplate" .}}
{{styleHeader "USAGE:"}} {{template "usageTemplate" .}}{{if .Category}}
{{styleHeader "CATEGORY:"}} {{.Category}}{{end}}{{if .Description}}
{{styleHeader "DESCRIPTION:"}} {{template "descriptionTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
{{styleHeader "OPTIONS:"}}{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}}
{{styleHeader "OPTIONS:"}}{{template "visibleFlagTemplate" .}}{{end}}`
// SubcommandHelpTemplate uses the default template structure with stylingconst SubcommandHelpTemplate = `{{styleHeader "NAME:"}} {{template "helpNameTemplate" .}}
{{styleHeader "USAGE:"}} {{template "usageTemplate" .}}{{if .Category}}
{{styleHeader "CATEGORY:"}} {{.Category}}{{end}}{{if .Description}}
{{styleHeader "DESCRIPTION:"}} {{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}}
{{styleHeader "COMMANDS:"}}{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
{{styleHeader "OPTIONS:"}}{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}}
{{styleHeader "OPTIONS:"}}{{template "visibleFlagTemplate" .}}{{end}}`