cli

package
v0.1.147 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymbolSuccess = "✓"
	SymbolError   = "✗"
	SymbolWarning = "!"
	SymbolInfo    = "→"
	SymbolBullet  = "•"
)

Symbols for consistent visual language

Variables

View Source
var (
	Version = "dev"
	Release = "false" // "true" in release builds
)

Build information (injected at compile time via ldflags)

View Source
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

View Source
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

View Source
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

View Source
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 Execute

func Execute() error

Execute runs the CLI

func FormatError

func FormatError(err error) string

FormatError converts an error to a human-readable message. It handles gRPC errors specially, converting them to friendly messages.

func FormatRelativeTime

func FormatRelativeTime(timestamp string) string

FormatRelativeTime formats a timestamp as relative time (e.g., "2 hours ago")

func GetErrorSuggestions

func GetErrorSuggestions(err error) []string

GetErrorSuggestions returns helpful suggestions for an error

func IndentedStyle

func IndentedStyle(level int) lipgloss.Style

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

func NeedsTLS(addr string) bool

NeedsTLS returns true if the address requires TLS. Delegates to common.NeedsTLS for consistent TLS detection.

func PrintBullet

func PrintBullet(text string)

PrintBullet prints a bulleted item

func PrintConnectionError

func PrintConnectionError(addr string, err error)

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

func PrintFormattedError(title string, err error)

PrintFormattedError prints an error with styling and optional suggestions

func PrintHeader

func PrintHeader(title string)

PrintHeader prints a section header

func PrintHint

func PrintHint(msg string)

PrintHint prints a subtle hint/suggestion

func PrintIndented

func PrintIndented(text string, level int)

PrintIndented prints text with indentation

func PrintInfo

func PrintInfo(msg string)

PrintInfo prints an info message with an arrow

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

func PrintKeyValueStyled(key, value string, valueStyle lipgloss.Style)

PrintKeyValueStyled prints a key-value pair with a custom value style

func PrintMountStatus

func PrintMountStatus(mountPoint, gateway, mode string, paths map[string]string)

PrintMountStatus prints the mount status display

func PrintNewline

func PrintNewline()

PrintNewline prints an empty line

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

func PrintSuggestions(title string, suggestions []string)

PrintSuggestions prints a list of suggestions

func PrintWarning

func PrintWarning(msg string)

PrintWarning prints a warning message with a yellow indicator

func RunSpinner

func RunSpinner(title string, fn func() error) error

RunSpinner runs a single action with a spinner

func RunSpinnerCtx

func RunSpinnerCtx(ctx context.Context, title string, fn func(ctx context.Context) error) error

RunSpinnerCtx runs an action with a spinner and context

func RunSpinnerWithResult

func RunSpinnerWithResult(title string, fn func() error) error

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 SetJSONOutput

func SetJSONOutput(enabled bool)

SetJSONOutput sets the JSON output mode

func SimpleSpinner

func SimpleSpinner(title string, fn func() error) error

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

func SpinnerWithValue(title string, fn func() (string, error)) error

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 Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to maxLen, adding "..." if needed

func WaitWithSpinner

func WaitWithSpinner(title string, duration time.Duration)

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

func NewClient

func NewClient(addr, token string) (*Client, error)

NewClient creates a new gRPC client

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC connection

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

func (*MountSpinner) Run

func (m *MountSpinner) Run() error

Run executes all steps in sequence

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

type StatusInfo added in v0.1.18

type StatusInfo struct {
	Running bool   `json:"running"`
	PID     int    `json:"pid,omitempty"`
	Mount   string `json:"mount,omitempty"`
	Mounted bool   `json:"mounted"`
}

type Table

type Table struct {
	Headers []string
	Rows    [][]string
	Widths  []int
}

Table represents a styled table

func NewTable

func NewTable(headers ...string) *Table

NewTable creates a new table with the given headers

func (*Table) AddRow

func (t *Table) AddRow(cells ...string)

AddRow adds a row to the table

func (*Table) Print

func (t *Table) Print()

Print renders the table to stdout

Jump to

Keyboard shortcuts

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