Documentation
¶
Index ¶
- Constants
- Variables
- func APIURL() string
- func DashboardURL() string
- func Execute() error
- func FormatError(err error) string
- func FormatRelativeTime(timestamp string) string
- func GetErrorSuggestions(err error) []string
- func IndentedStyle(level int) lipgloss.Style
- func IsJSONOutput() bool
- func LoadCredentials() string
- func NeedsTLS(addr string) bool
- func PrintBullet(text string)
- func PrintConnectionError(addr string, err error)
- func PrintError(err error)
- func PrintErrorMsg(msg string)
- func PrintFormattedError(title string, err error)
- func PrintHeader(title string)
- func PrintHint(msg string)
- func PrintIndented(text string, level int)
- func PrintInfo(msg string)
- func PrintInfof(format string, args ...interface{})
- func PrintJSON(data interface{}) bool
- func PrintKeyValue(key, value string)
- func PrintKeyValueStyled(key, value string, valueStyle lipgloss.Style)
- func PrintMountStatus(mountPoint, gateway, mode string, paths map[string]string)
- func PrintNewline()
- func PrintSuccess(msg string)
- func PrintSuccessWithValue(msg, value string)
- func PrintSuccessf(format string, args ...interface{})
- func PrintSuggestions(title string, suggestions []string)
- func PrintWarning(msg string)
- func RunSpinner(title string, fn func() error) error
- func RunSpinnerCtx(ctx context.Context, title string, fn func(ctx context.Context) error) error
- func RunSpinnerWithResult(title string, fn func() error) error
- func RunSteps(steps []SpinnerStep) error
- func SetJSONOutput(enabled bool)
- func SimpleSpinner(title string, fn func() error) error
- func SpinnerWithValue(title string, fn func() (string, error)) error
- func TransportCredentials(addr string) credentials.TransportCredentials
- func Truncate(s string, maxLen int) string
- func WaitWithSpinner(title string, duration time.Duration)
- type Client
- type MountSpinner
- type SpinnerAction
- type SpinnerStep
- type StatusInfo
- type Table
Constants ¶
const ( SymbolSuccess = "✓" SymbolError = "✗" SymbolWarning = "!" SymbolInfo = "→" SymbolBullet = "•" )
Symbols for consistent visual language
Variables ¶
var ( Version = "dev" Release = "false" // "true" in release builds )
Build information (injected at compile time via ldflags)
var ( ColorPrimary = lipgloss.Color("#8B5CF6") // Purple - brand color ColorSuccess = lipgloss.Color("#22C55E") // Green ColorWarning = lipgloss.Color("#F59E0B") // Amber ColorError = lipgloss.Color("#EF4444") // Red ColorInfo = lipgloss.Color("#3B82F6") // Blue ColorSubtle = lipgloss.Color("#6B7280") // Gray ColorMuted = lipgloss.Color("#9CA3AF") // Light gray )
Color palette - professional, subtle colors inspired by modern CLIs
var ( // Brand BrandStyle = lipgloss.NewStyle(). Bold(true). Foreground(ColorPrimary) // Status styles SuccessStyle = lipgloss.NewStyle(). Foreground(ColorSuccess) ErrorStyle = lipgloss.NewStyle(). Foreground(ColorError). Bold(true) WarningStyle = lipgloss.NewStyle(). Foreground(ColorWarning) InfoStyle = lipgloss.NewStyle(). Foreground(ColorInfo) // Text variations BoldStyle = lipgloss.NewStyle(). Bold(true) DimStyle = lipgloss.NewStyle(). Foreground(ColorSubtle) MutedStyle = lipgloss.NewStyle(). Foreground(ColorMuted) // Key-value styles KeyStyle = lipgloss.NewStyle(). Foreground(ColorSubtle). Width(12) ValueStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#FFFFFF")) // Table styles TableHeaderStyle = lipgloss.NewStyle(). Bold(true). Foreground(ColorSubtle) TableCellStyle = lipgloss.NewStyle() // Section styles SectionTitleStyle = lipgloss.NewStyle(). Bold(true). MarginTop(1). MarginBottom(1) // Box styles for status displays StatusBoxStyle = lipgloss.NewStyle(). Padding(1, 2). MarginTop(1) // Code/path style CodeStyle = lipgloss.NewStyle(). Foreground(ColorPrimary) // Hint style for suggestions HintStyle = lipgloss.NewStyle(). Foreground(ColorMuted). Italic(true) )
Text styles
var RPCErrorMessages = map[codes.Code]string{ codes.Unauthenticated: "Authentication failed - invalid or missing token", codes.PermissionDenied: "Access denied - you don't have permission for this action", codes.NotFound: "Resource not found", codes.AlreadyExists: "Resource already exists", codes.InvalidArgument: "Invalid request parameters", codes.Unavailable: "Service unavailable - the gateway may be down or unreachable", codes.DeadlineExceeded: "Request timed out", codes.ResourceExhausted: "Rate limit exceeded - please try again later", codes.Internal: "Internal server error", codes.Unimplemented: "This feature is not yet available", codes.Canceled: "Request was canceled", codes.FailedPrecondition: "Operation cannot be performed in current state", codes.Aborted: "Operation was aborted", codes.OutOfRange: "Value out of valid range", codes.DataLoss: "Unrecoverable data loss or corruption", }
RPCErrorMessages maps gRPC error codes to human-readable messages
var RPCErrorSuggestions = map[codes.Code][]string{ codes.Unauthenticated: { "Check that your token is correct: " + CodeStyle.Render("--token <token>"), "Generate a new token in the dashboard if needed", }, codes.PermissionDenied: { "Verify you have access to this workspace", "Check with your team admin for permissions", }, codes.Unavailable: { "Check that the gateway is running", "Verify the gateway address: " + CodeStyle.Render("--gateway <addr>"), "Try again in a few moments", }, codes.DeadlineExceeded: { "The server may be under heavy load", "Try again with a simpler request", }, }
RPCErrorSuggestions provides helpful suggestions for specific error codes
Functions ¶
func APIURL ¶ added in v0.1.18
func APIURL() string
APIURL returns the backend API URL based on build type
func DashboardURL ¶ added in v0.1.18
func DashboardURL() string
DashboardURL returns the dashboard URL based on build type
func FormatError ¶
FormatError converts an error to a human-readable message. It handles gRPC errors specially, converting them to friendly messages.
func FormatRelativeTime ¶
FormatRelativeTime formats a timestamp as relative time (e.g., "2 hours ago")
func GetErrorSuggestions ¶
GetErrorSuggestions returns helpful suggestions for an error
func IndentedStyle ¶
IndentedStyle returns a style with the given indent level (2 spaces per level)
func IsJSONOutput ¶
func IsJSONOutput() bool
IsJSONOutput returns true if JSON output mode is enabled
func LoadCredentials ¶ added in v0.1.18
func LoadCredentials() string
LoadCredentials returns empty string in OSS builds (no login support).
func NeedsTLS ¶ added in v0.1.7
NeedsTLS returns true if the address requires TLS. Delegates to common.NeedsTLS for consistent TLS detection.
func PrintConnectionError ¶
PrintConnectionError prints a styled connection error with suggestions
func PrintError ¶
func PrintError(err error)
PrintError prints a formatted error with suggestions for gRPC errors.
func PrintErrorMsg ¶
func PrintErrorMsg(msg string)
PrintErrorMsg prints a simple error message string
func PrintFormattedError ¶
PrintFormattedError prints an error with styling and optional suggestions
func PrintIndented ¶
PrintIndented prints text with indentation
func PrintInfof ¶
func PrintInfof(format string, args ...interface{})
PrintInfof prints a formatted info message
func PrintJSON ¶
func PrintJSON(data interface{}) bool
PrintJSON outputs data as JSON if JSON mode is enabled, returns true if it did
func PrintKeyValue ¶
func PrintKeyValue(key, value string)
PrintKeyValue prints a key-value pair with consistent alignment
func PrintKeyValueStyled ¶
PrintKeyValueStyled prints a key-value pair with a custom value style
func PrintMountStatus ¶
PrintMountStatus prints the mount status display
func PrintSuccess ¶
func PrintSuccess(msg string)
PrintSuccess prints a success message with a green checkmark
func PrintSuccessWithValue ¶
func PrintSuccessWithValue(msg, value string)
PrintSuccessWithValue prints a success message with a right-aligned value
func PrintSuccessf ¶
func PrintSuccessf(format string, args ...interface{})
PrintSuccessf prints a formatted success message
func PrintSuggestions ¶
PrintSuggestions prints a list of suggestions
func PrintWarning ¶
func PrintWarning(msg string)
PrintWarning prints a warning message with a yellow indicator
func RunSpinner ¶
RunSpinner runs a single action with a spinner
func RunSpinnerCtx ¶
RunSpinnerCtx runs an action with a spinner and context
func RunSpinnerWithResult ¶
RunSpinnerWithResult runs an action with a spinner and returns any error
func RunSteps ¶
func RunSteps(steps []SpinnerStep) error
RunSteps executes a series of steps with spinners, showing success after each
func SimpleSpinner ¶
SimpleSpinner shows a spinner with a simple title and runs the action On success, prints a success message. On error, prints error and returns it.
func SpinnerWithValue ¶
SpinnerWithValue runs an action and shows the result value on success
func TransportCredentials ¶ added in v0.1.7
func TransportCredentials(addr string) credentials.TransportCredentials
TransportCredentials returns TLS or insecure credentials based on the address. Delegates to common.TransportCredentials for consistent TLS detection.
func WaitWithSpinner ¶
WaitWithSpinner shows a spinner while waiting for a duration
Types ¶
type Client ¶
type Client struct {
Gateway pb.GatewayServiceClient
Agents pb.AgentServiceClient
Tools pb.ToolServiceClient
Context pb.ContextServiceClient
// contains filtered or unexported fields
}
Client wraps gRPC connections to the gateway
type MountSpinner ¶
type MountSpinner struct {
// contains filtered or unexported fields
}
MountSpinner is specifically for mount operations that need to show status
func NewMountSpinner ¶
func NewMountSpinner() *MountSpinner
NewMountSpinner creates a new mount spinner sequence
func (*MountSpinner) AddStep ¶
func (m *MountSpinner) AddStep(title, successMsg string, fn func() error) *MountSpinner
AddStep adds a step to the mount sequence
func (*MountSpinner) AddStepWithValue ¶
func (m *MountSpinner) AddStepWithValue(title, successMsg string, valueFn func() (string, error)) *MountSpinner
AddStepWithValue adds a step that shows a value on completion
type SpinnerAction ¶
type SpinnerAction struct {
Title string
SuccessMsg string
SuccessVal string // Optional value to show after success
Action func() error
ActionCtx func(ctx context.Context) error
}
SpinnerAction represents a step with a spinner
type SpinnerStep ¶
type SpinnerStep struct {
Title string
SuccessMsg string
Value string // Optional value to display on success
Run func() error
}
SpinnerStep represents a step in a multi-step process