utils

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source

Logo is the ASCII art logo displayed in help output.

Variables

View Source
var (
	Version   = "dev"
	BuildTime = "unknown"
)

Version info set by the commands package at init time.

View Source
var HelpTemplate = `
{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
View Source
var UsageTemplate = Logo + `{{versionInfo}}

Usage:{{if .Runnable}}
  {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
  {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}

Aliases:
  {{.NameAndAliases}}{{end}}{{if .HasExample}}

Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}

Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}

Flags:
{{wrappedFlagUsages .LocalFlags | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}

Global Flags:
{{wrappedFlagUsages .InheritedFlags | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}

Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}

Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`

UsageTemplate is identical to the default cobra usage template, but utilises WrappedFlagUsages to ensure flag usages don't wrap around. The logo and version info are prepended to the usage output.

Functions

func SetupLogger

func SetupLogger() (*zap.Logger, *os.File, error)

SetupLogger creates a zap logger instance that writes to a file. Due to the CLI heavily using bubbletea to provide interactive experiences, we log to a file by default.

func VersionInfo added in v0.2.0

func VersionInfo() string

VersionInfo returns a formatted string with version information.

func WrappedFlagUsages

func WrappedFlagUsages(cmd *pflag.FlagSet) string

WrappedFlagUsages wraps long descriptions for flags, this uses the users terminal size or width of 80 if cannot determine users width.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL