Documentation
¶
Overview ¶
Package notify provides context detection for smart hint generation.
Package notify provides a unified API for alerts and hints in the CLI.
Index ¶
- func Alert(alert *alerts.Alert) error
- func Error(message string, ctx hints.Context) error
- func Hints(ctx hints.Context) error
- func Info(message string, ctx hints.Context) error
- func SetDefault(notifier *Notifier)
- func Success(message string, ctx hints.Context) error
- func Warning(message string, ctx hints.Context) error
- type CommonContexts
- func (CommonContexts) AuthStatus(succeeded bool, providersConfigured int) hints.Context
- func (CommonContexts) AuthTest(succeeded bool, errorType string) hints.Context
- func (CommonContexts) Command(command, subcommand string, succeeded bool, errorType string) hints.Context
- func (CommonContexts) Validation(subcommand string, succeeded bool, errorType string) hints.Context
- type Config
- type ContextBuilder
- func (cb *ContextBuilder) Build() hints.Context
- func (cb *ContextBuilder) FromCommand(cmd *cobra.Command, args []string) *ContextBuilder
- func (cb *ContextBuilder) WithError(errorType string) *ContextBuilder
- func (cb *ContextBuilder) WithSuccess(succeeded bool) *ContextBuilder
- func (cb *ContextBuilder) WithUserState(userState hints.UserState) *ContextBuilder
- type Notifier
- func (n *Notifier) AddHintFunc(name string, fn func(hints.Context) []*hints.Hint)
- func (n *Notifier) AddHintProvider(provider hints.Provider)
- func (n *Notifier) Alert(alert *alerts.Alert) error
- func (n *Notifier) AlertWithHints(alert *alerts.Alert, ctx hints.Context) error
- func (n *Notifier) Error(message string, ctx hints.Context) error
- func (n *Notifier) Hints(ctx hints.Context) error
- func (n *Notifier) Info(message string, ctx hints.Context) error
- func (n *Notifier) Success(message string, ctx hints.Context) error
- func (n *Notifier) Warning(message string, ctx hints.Context) error
- func (n *Notifier) WithConfig(config Config) *Notifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommonContexts ¶
type CommonContexts struct{}
CommonContexts provides pre-built contexts for common scenarios.
var Contexts CommonContexts
Contexts is the global contexts instance for convenience.
func (CommonContexts) AuthStatus ¶
func (CommonContexts) AuthStatus(succeeded bool, providersConfigured int) hints.Context
AuthStatus creates a context for auth status commands.
func (CommonContexts) AuthTest ¶ added in v0.0.24
func (CommonContexts) AuthTest(succeeded bool, errorType string) hints.Context
AuthTest creates a context for auth testing commands.
func (CommonContexts) Command ¶
func (CommonContexts) Command(command, subcommand string, succeeded bool, errorType string) hints.Context
Command creates a context for generic command execution.
func (CommonContexts) Validation ¶
Validation creates a context for validation commands.
type Config ¶
type Config struct {
OutputFormat string // "table", "json", "yaml"
ShowHints bool // Whether to show hints
ShowAlerts bool // Whether to show alerts
MaxHints int // Maximum number of hints to show
AlertWriter io.Writer // Where to write alerts (default: stderr)
HintWriter io.Writer // Where to write hints (default: stdout)
UseColor bool // Whether to use colored output
}
Config controls notification behavior.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a sensible default configuration.
type ContextBuilder ¶
type ContextBuilder struct {
// contains filtered or unexported fields
}
ContextBuilder helps build hint contexts from command execution.
func NewContextBuilder ¶
func NewContextBuilder() *ContextBuilder
NewContextBuilder creates a new context builder.
func (*ContextBuilder) Build ¶
func (cb *ContextBuilder) Build() hints.Context
Build returns the constructed context.
func (*ContextBuilder) FromCommand ¶
func (cb *ContextBuilder) FromCommand(cmd *cobra.Command, args []string) *ContextBuilder
FromCommand configures the context from a Cobra command.
func (*ContextBuilder) WithError ¶
func (cb *ContextBuilder) WithError(errorType string) *ContextBuilder
WithError sets the error type for failed operations.
func (*ContextBuilder) WithSuccess ¶
func (cb *ContextBuilder) WithSuccess(succeeded bool) *ContextBuilder
WithSuccess sets the operation success status.
func (*ContextBuilder) WithUserState ¶
func (cb *ContextBuilder) WithUserState(userState hints.UserState) *ContextBuilder
WithUserState updates the user state information.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier is the main public API for sending alerts and displaying hints.
func GetDefault ¶
func GetDefault() *Notifier
GetDefault returns the default global notifier, creating one if needed.
func NewFromCommand ¶
NewFromCommand creates a Notifier configured from a Cobra command.
func (*Notifier) AddHintFunc ¶
AddHintFunc registers a function as a hint provider.
func (*Notifier) AddHintProvider ¶
AddHintProvider registers a custom hint provider.
func (*Notifier) AlertWithHints ¶
AlertWithHints sends an alert and displays contextual hints.
func (*Notifier) WithConfig ¶
WithConfig creates a new Notifier with updated configuration.