Documentation
¶
Index ¶
- Constants
- func Bold(s string) string
- func ChooseConfigFile(explicitPath string) (string, error)
- func ClearDown()
- func ClearLine()
- func Cyan(s string) string
- func Dim(s string) string
- func Green(s string) string
- func HideCursor()
- func LogCmd(s *Session, parts ...string)
- func MoveDown(n int)
- func MoveToColumn(n int)
- func MoveUp(n int)
- func PromptConfirm(label string) (bool, error)
- func PromptText(label string, required bool) (string, error)
- func RawMode() (restore func(), err error)
- func Red(s string) string
- func Reverse(s string) string
- func RunREPL(s *Session) error
- func RunTUI(explicitConfig string) error
- func ShowCursor()
- func Yellow(s string) string
- type Cache
- func (c *Cache) Get(resourceType string) []NamedItem
- func (c *Cache) Invalidate(resourceType string)
- func (c *Cache) InvalidateAll()
- func (c *Cache) InvalidateFiltered()
- func (c *Cache) LookupByID(resourceType, id string) *NamedItem
- func (c *Cache) LookupByName(resourceType, name string) *NamedItem
- func (c *Cache) Set(resourceType string, items []NamedItem)
- type Command
- type FetchFunc
- type KeyEvent
- type LoginFunc
- type NamedItem
- type Resolver
- func (r *Resolver) Fetch(ctx context.Context, resourceType string) ([]NamedItem, error)
- func (r *Resolver) RegisterFetcher(resourceType string, fn FetchFunc)
- func (r *Resolver) Resolve(ctx context.Context, resourceType, label string) (*NamedItem, error)
- func (r *Resolver) ResolveID(resourceType, id string) string
- func (r *Resolver) ResolveWithArgs(ctx context.Context, resourceType, label string, args []string) (*NamedItem, error)
- func (r *Resolver) SelectFromItems(label string, items []NamedItem) (*NamedItem, error)
- type Scope
- type SelectItem
- type Session
- type SpecialKey
Constants ¶
const ( KeyEnter = '\r' KeyNewline = '\n' KeyEscape = 27 KeyBackspace = 127 KeyCtrlC = 3 KeyCtrlD = 4 )
Variables ¶
This section is empty.
Functions ¶
func ChooseConfigFile ¶
ChooseConfigFile scans ~/.carbide for config*.yaml files and shows an interactive selector if multiple configs exist. Returns the chosen path, or empty string if only one config exists (use default) or no terminal is available.
func HideCursor ¶
func HideCursor()
func MoveToColumn ¶
func MoveToColumn(n int)
func PromptConfirm ¶
PromptConfirm displays a y/N confirmation prompt.
func PromptText ¶
PromptText displays a label and reads a line of text input.
func RunTUI ¶
RunTUI is the entry point for carbidecli tui. It handles config selection, authentication, and starts the REPL.
func ShowCursor ¶
func ShowCursor()
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds lazy-loaded resources for the interactive session with a TTL.
func (*Cache) Invalidate ¶
func (*Cache) InvalidateAll ¶
func (c *Cache) InvalidateAll()
func (*Cache) InvalidateFiltered ¶
func (c *Cache) InvalidateFiltered()
func (*Cache) LookupByID ¶
func (*Cache) LookupByName ¶
type KeyEvent ¶
type KeyEvent struct {
Char byte
Special SpecialKey
}
type NamedItem ¶
type NamedItem struct {
Name string
ID string
Status string
Extra map[string]string
Raw interface{}
}
NamedItem is a generic resource with a human-readable name and UUID.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves resource names to UUIDs using the cache and interactive select.
func NewResolver ¶
func (*Resolver) RegisterFetcher ¶
func (*Resolver) ResolveWithArgs ¶
type SelectItem ¶
SelectItem represents one option in a select menu.
func Select ¶
func Select(label string, items []SelectItem) (*SelectItem, error)
Select displays an interactive arrow-key menu and returns the selected item. For large lists it shows a scrolling window of selectWindowSize items.
type Session ¶
type Session struct {
Client *carbidecli.Client
ConfigPath string
Org string
Token string
Scope Scope
Cache *Cache
Resolver *Resolver
LoginFn LoginFunc
}
Session holds the shared state for an interactive TUI session.
func NewSession ¶
func NewSession(client *carbidecli.Client, org, configPath string) *Session
NewSession creates a new interactive session.
func (*Session) PromptString ¶
PromptString returns the prompt showing org and current scope.
func (*Session) RefreshClient ¶
RefreshClient updates the session with a new token.
type SpecialKey ¶
type SpecialKey int
const ( KeyNone SpecialKey = iota KeyUp KeyDown KeyRight KeyLeft )