Documentation
¶
Overview ¶
Package hints provides formatting for hints in different output formats.
Package hints provides actionable user guidance for CLI operations.
Package hints provides context-aware hint providers for Starmap CLI.
Index ¶
- func Display(w io.Writer, format format.Format, hints []*Hint) error
- func DisplayHint(w io.Writer, format format.Format, hint *Hint) error
- func RegisterStarmapProviders(registry *Registry)
- type Context
- type Environment
- type Formatter
- type FormatterConfig
- type Hint
- type Provider
- type ProviderFunc
- type Registry
- type RegistryConfig
- type UserState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayHint ¶
DisplayHint is a convenience function to format and display a single hint.
func RegisterStarmapProviders ¶
func RegisterStarmapProviders(registry *Registry)
RegisterStarmapProviders registers all standard Starmap hint providers.
Types ¶
type Context ¶
type Context struct {
Command string // Current command being executed
Subcommand string // Subcommand if applicable
Succeeded bool // Whether the operation succeeded
ErrorType string // Type of error if failed
Args []string // Command arguments
Flags map[string]string // Command flags
UserState UserState // Current user state
Environment Environment // Runtime environment
}
Context provides information for generating contextual hints.
type Environment ¶
type Environment struct {
IsTerminal bool // Whether running in a terminal
IsCI bool // Whether running in CI/CD
Shell string // Shell type (bash, zsh, etc.)
OS string // Operating system
WorkingDir string // Current working directory
IsGitRepo bool // Whether in a git repository
}
Environment represents the runtime environment.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats hints for different output types.
func NewFormatter ¶
NewFormatter creates a new hint formatter.
func (*Formatter) FormatHint ¶
FormatHint formats and writes a single hint.
func (*Formatter) FormatHints ¶
FormatHints formats and writes a slice of hints.
func (*Formatter) WithConfig ¶
func (f *Formatter) WithConfig(config FormatterConfig) *Formatter
WithConfig sets the formatter configuration.
type FormatterConfig ¶
type FormatterConfig struct {
ShowIcons bool // Whether to show emoji icons
MaxWidth int // Maximum width for text wrapping
IndentSize int // Indentation size for structured output
}
FormatterConfig configures hint formatting behavior.
type Hint ¶
type Hint struct {
Message string // Human-readable guidance message
Command string // Optional specific command to run
URL string // Optional documentation link
Tags []string // For context-aware filtering
}
Hint represents actionable user guidance.
func NewCommand ¶
NewCommand creates a new hint with a specific command.
func (*Hint) WithCommand ¶
WithCommand adds a command to the hint.
type ProviderFunc ¶
ProviderFunc is an adapter to allow functions to be used as Providers.
func (ProviderFunc) GetHints ¶
func (f ProviderFunc) GetHints(ctx Context) []*Hint
GetHints calls the function.
func (ProviderFunc) Name ¶
func (f ProviderFunc) Name() string
Name returns the function name (generic).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages hint providers and generates contextual hints.
func (*Registry) RegisterFunc ¶
RegisterFunc registers a function as a hint provider.
func (*Registry) WithConfig ¶
func (r *Registry) WithConfig(config RegistryConfig) *Registry
WithConfig sets the registry configuration.
type RegistryConfig ¶
type RegistryConfig struct {
MaxHints int // Maximum number of hints to return
FilterTags []string // Only include hints with these tags
ExcludeTags []string // Exclude hints with these tags
Enabled bool // Whether hints are enabled
}
RegistryConfig configures hint generation behavior.
type UserState ¶
type UserState struct {
AuthProviders []string // Configured authentication providers
HasConfig bool // Whether user has configuration file
IsFirstRun bool // Whether this is the first time running
LastCommand string // Last successful command
ConfiguredOutput string // User's preferred output format
}
UserState represents the current state of user configuration.