cli

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyStyledHelpRecursive

func ApplyStyledHelpRecursive(cmd *cobra.Command)

ApplyStyledHelpRecursive applies styled help and usage to a command and all its subcommands. Call this after all subcommands have been added, before Execute().

func Execute

func Execute(cmd *cobra.Command) error

Execute applies styled help to all subcommands and executes the command. Use this instead of cmd.Execute() to get consistent Grove styling.

func ExecuteContext

func ExecuteContext(ctx context.Context, cmd *cobra.Command) error

ExecuteContext applies styled help and executes the command with context. Use this instead of cmd.ExecuteContext() to get consistent Grove styling.

func GetLogger

func GetLogger(cmd *cobra.Command) *logrus.Logger

GetLogger creates a logger based on command flags

func InitConfig

func InitConfig(configFile string) (string, error)

InitConfig initializes the configuration file path

func NewDocsCommand

func NewDocsCommand(docsJSON []byte) *cobra.Command

NewDocsCommand creates a standard 'docs' command that prints embedded JSON documentation.

func NewLogger

func NewLogger(opts ...LoggerOption) *logrus.Logger

NewLogger creates a new logger with options

func NewStandardCommand

func NewStandardCommand(use, short string) *cobra.Command

NewStandardCommand creates a new command with standard Grove flags. After adding all subcommands, call Execute(cmd) to run with styled help.

func NewVersionCommand

func NewVersionCommand(componentName string, info VersionInfo) *cobra.Command

NewVersionCommand creates a standard version command

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens the specified URL in the default browser

func PrintError

func PrintError(cmd *cobra.Command, err error)

PrintError prints a styled error message to stderr with help hint.

func SetStyledHelp

func SetStyledHelp(cmd *cobra.Command)

SetStyledHelp applies consistent Grove styling to a command's help output. Call this on the root command before Execute().

func SetStyledHelpWithExtras

func SetStyledHelpWithExtras(cmd *cobra.Command, extras HelpExtrasFunc)

SetStyledHelpWithExtras applies Grove styling with additional custom sections. The extras function is called after COMMANDS but before the help hint.

func SetVersionTemplate

func SetVersionTemplate(cmd *cobra.Command, info VersionInfo)

SetVersionTemplate sets a custom version template for a cobra command

Types

type CommandOptions

type CommandOptions struct {
	ConfigFile string
	Verbose    bool
	JSONOutput bool
}

CommandOptions holds common options for Grove commands

func GetOptions

func GetOptions(cmd *cobra.Command) CommandOptions

GetOptions extracts common options from a command

type ErrorHandler

type ErrorHandler struct {
	Verbose bool
}

ErrorHandler provides user-friendly error messages

func NewErrorHandler

func NewErrorHandler(verbose bool) *ErrorHandler

NewErrorHandler creates a new error handler

func (*ErrorHandler) Handle

func (h *ErrorHandler) Handle(err error) error

Handle provides user-friendly error messages based on error type

type HelpExtrasFunc

type HelpExtrasFunc func(t *theme.Theme)

HelpExtrasFunc is a callback that renders additional help sections. It receives the theme for consistent styling.

type LoggerOption

type LoggerOption func(*logrus.Logger)

LoggerOption represents a function that configures a logger

func WithFormatter

func WithFormatter(formatter logrus.Formatter) LoggerOption

WithFormatter sets the log formatter

func WithLevel

func WithLevel(level logrus.Level) LoggerOption

WithLevel sets the log level

func WithOutput

func WithOutput(w io.Writer) LoggerOption

WithOutput sets the logger output

type ProgressReporter

type ProgressReporter struct {
	// contains filtered or unexported fields
}

ProgressReporter reports concurrent operation progress

func NewProgressReporter

func NewProgressReporter() *ProgressReporter

NewProgressReporter creates a new progress reporter

func (*ProgressReporter) Done

func (p *ProgressReporter) Done()

Done marks the operation as complete

func (*ProgressReporter) Update

func (p *ProgressReporter) Update(service, status string)

Update updates the status of a service

type VersionInfo

type VersionInfo struct {
	Version   string
	Commit    string
	BuildDate string
	BuildArch string
}

VersionInfo holds version information for a Grove component

Jump to

Keyboard shortcuts

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