Documentation ¶
Index ¶
- Constants
- Variables
- func Ago(now, t time.Time) string
- func CmdHandler(msg tea.Msg) tea.Cmd
- func ModuleIcon() string
- func ModulePath(modulePath string) string
- func ModulePathWithIcon(modulePath string, squareBrackets bool) string
- func NavigateTo(kind Kind, opts ...NavigateOption) tea.Cmd
- func OpenEditor(path string) tea.Cmd
- func ReportError(err error) tea.Cmd
- func ReportInfo(msg string, args ...any) tea.Cmd
- func SanitizeColors(b []byte) []byte
- func Scrollbar(height, total, visible, offset int) string
- func WorkspaceIcon() string
- func WorkspaceName(name string) string
- func WorkspaceNameWithIcon(name string, squareBrackets bool) string
- func YesNoPrompt(prompt string, action tea.Cmd) tea.Cmd
- type ActionHandler
- type BorderPosition
- type Cache
- type ChildModel
- type ErrorMsg
- type FilterBlurMsg
- type FilterCloseMsg
- type FilterFocusReqMsg
- type FilterKeyMsg
- type Helpers
- func (h *Helpers) CostSummary(report workspace.CostSummary, inherit lipgloss.Style) string
- func (h *Helpers) CreateTasks(fn task.SpecFunc, ids ...resource.ID) tea.Cmd
- func (h *Helpers) CreateTasksWithSpecs(specs ...task.Spec) tea.Cmd
- func (h *Helpers) CurrentWorkspaceName(workspaceID *resource.ID) string
- func (h *Helpers) GroupReport(group *task.Group, table bool) string
- func (h *Helpers) ModuleCost(mod *module.Module) string
- func (h *Helpers) ModuleCurrentResourceCount(mod *module.Module) string
- func (h *Helpers) ModuleCurrentWorkspace(mod *module.Module) *workspace.Workspace
- func (h *Helpers) Move(workspaceID resource.ID, from state.ResourceAddress) tea.Cmd
- func (h *Helpers) ResourceReport(report plan.Report, inherit lipgloss.Style) string
- func (h *Helpers) StateReloadReport(report state.ReloadSummary, inherit lipgloss.Style) string
- func (h *Helpers) TaskModule(t *task.Task) *module.Module
- func (h *Helpers) TaskModulePath(t *task.Task) string
- func (h *Helpers) TaskModulePathWithIcon(t *task.Task) string
- func (h *Helpers) TaskStatus(t *task.Task, table bool) string
- func (h *Helpers) TaskSummary(t *task.Task, table bool) string
- func (h *Helpers) TaskWorkspace(t *task.Task) *workspace.Workspace
- func (h *Helpers) TaskWorkspaceName(t *task.Task) string
- func (h *Helpers) TaskWorkspaceNameWithIcon(t *task.Task) string
- func (h *Helpers) WorkspaceCost(ws *workspace.Workspace) string
- func (h *Helpers) WorkspaceCurrentCheckmark(ws *workspace.Workspace) string
- func (h *Helpers) WorkspaceReloadReport(report workspace.ReloadSummary, inherit lipgloss.Style) string
- func (h *Helpers) WorkspaceResourceCount(ws *workspace.Workspace) string
- type IDRetriever
- type InfoMsg
- type Kind
- type Maker
- type ModelHelpBindings
- type NavigateOption
- type NavigationMsg
- type Page
- type PaneManager
- type Position
- type Prompt
- type PromptAction
- type PromptMsg
- type Viewport
- type ViewportOptions
Constants ¶
const ( Black = lipgloss.Color("#000000") DarkRed = lipgloss.Color("#FF0000") Red = lipgloss.Color("#FF5353") Purple = lipgloss.Color("135") Orange = lipgloss.Color("214") BurntOrange = lipgloss.Color("214") Yellow = lipgloss.Color("#DBBD70") Green = lipgloss.Color("34") Turquoise = lipgloss.Color("86") DarkGreen = lipgloss.Color("#325451") LightGreen = lipgloss.Color("47") GreenBlue = lipgloss.Color("#00A095") DeepBlue = lipgloss.Color("39") LightBlue = lipgloss.Color("81") LightishBlue = lipgloss.Color("75") Blue = lipgloss.Color("63") Violet = lipgloss.Color("13") Grey = lipgloss.Color("#737373") LightGrey = lipgloss.Color("245") LighterGrey = lipgloss.Color("250") EvenLighterGrey = lipgloss.Color("253") DarkGrey = lipgloss.Color("#606362") White = lipgloss.Color("#ffffff") OffWhite = lipgloss.Color("#a8a7a5") HotPink = lipgloss.Color("200") )
const ( // MinHeight is the minimum height of the TUI. MinHeight = 24 // Height of prompt including borders PromptHeight = 3 FooterHeight = 1 // Height of help widget, including borders HelpWidgetHeight = 12 // MinContentHeight is the minimum height of content above the footer. MinContentHeight = MinHeight - FooterHeight // MinContentWidth is the minimum width of the content. MinContentWidth = 80 )
const (
DirIcon string = ""
)
const (
ScrollbarWidth = 1
)
Variables ¶
var ( DebugLogLevel = Blue InfoLogLevel = lipgloss.AdaptiveColor{Dark: string(Turquoise), Light: string(Green)} ErrorLogLevel = Red WarnLogLevel = Yellow LogRecordAttributeKey = lipgloss.AdaptiveColor{Dark: string(LightGrey), Light: string(LightGrey)} HelpKey = lipgloss.AdaptiveColor{ Dark: "ff", Light: "", } HelpDesc = lipgloss.AdaptiveColor{ Dark: "248", Light: "246", } InactivePreviewBorder = lipgloss.AdaptiveColor{ Dark: "244", Light: "250", } CurrentBackground = Grey CurrentForeground = White SelectedBackground = lipgloss.Color("110") SelectedForeground = Black CurrentAndSelectedBackground = lipgloss.Color("117") CurrentAndSelectedForeground = Black TitleColor = lipgloss.AdaptiveColor{ Dark: "", Light: "", } GroupReportBackgroundColor = EvenLighterGrey TaskSummaryBackgroundColor = EvenLighterGrey ScrollPercentageBackground = lipgloss.AdaptiveColor{ Dark: string(DarkGrey), Light: string(EvenLighterGrey), } )
var ( Regular = lipgloss.NewStyle() Bold = Regular.Bold(true) Padded = Regular.Padding(0, 1) Border = Regular.Border(lipgloss.NormalBorder()) ThickBorder = Regular.Border(lipgloss.ThickBorder()).BorderForeground(Violet) ModuleStyle = Regular.Foreground(lipgloss.AdaptiveColor{ Dark: string(LightishBlue), Light: "27", }) WorkspaceStyle = Regular.Foreground(Purple) )
Functions ¶
func ModuleIcon ¶ added in v0.6.0
func ModuleIcon() string
func ModulePath ¶ added in v0.6.0
func ModulePathWithIcon ¶ added in v0.6.0
func NavigateTo ¶
func NavigateTo(kind Kind, opts ...NavigateOption) tea.Cmd
NavigateTo sends an instruction to navigate to a page with the given model kind, and optionally parent resource.
func OpenEditor ¶ added in v0.2.0
func ReportError ¶
func SanitizeColors ¶ added in v0.5.3
SanitizeColors ensures ANSI color codes are reset before a newline and re-activated on the next line. This is necessary when ANSI color-coded strings are wrapped in a pane where there is more than one vertical pane.
func WorkspaceIcon ¶ added in v0.6.0
func WorkspaceIcon() string
func WorkspaceName ¶ added in v0.6.0
func WorkspaceNameWithIcon ¶ added in v0.6.0
Types ¶
type ActionHandler ¶ added in v0.6.0
type ActionHandler struct { *Helpers IDRetriever }
ActionHandler handles actions common to more than one model.
func (*ActionHandler) HelpBindings ¶ added in v0.6.0
func (m *ActionHandler) HelpBindings() []key.Binding
type BorderPosition ¶ added in v0.6.0
type BorderPosition int
const ( TopLeftBorder BorderPosition = iota TopMiddleBorder TopRightBorder BottomLeftBorder BottomMiddleBorder BottomRightBorder )
type Cache ¶ added in v0.2.0
type Cache struct {
// contains filtered or unexported fields
}
page Cache: not so much for performance but to retain memory of user actions, e.g. a user may select a particular row in a table, navigate away from the page and later return to the page, and they would expect the same row still to be selected.
func (*Cache) Get ¶ added in v0.2.0
func (c *Cache) Get(page Page) ChildModel
func (*Cache) Put ¶ added in v0.2.0
func (c *Cache) Put(page Page, model ChildModel)
type ChildModel ¶ added in v0.6.0
type FilterBlurMsg ¶ added in v0.1.9
type FilterBlurMsg struct{}
FilterBlurMsg is a request to unfocus the filter widget. It is not acknowledged.
type FilterCloseMsg ¶ added in v0.1.9
type FilterCloseMsg struct{}
FilterCloseMsg is a request to close the filter widget. It is not acknowledged.
type FilterFocusReqMsg ¶ added in v0.1.9
type FilterFocusReqMsg struct{}
FilterFocusReqMsg is a request to focus the filter widget.
type FilterKeyMsg ¶ added in v0.1.9
FilterKeyMsg is a key entered by the user into the filter widget
type Helpers ¶
type Helpers struct { Modules *module.Service Workspaces *workspace.Service Plans *plan.Service Tasks *task.Service States *state.Service Logger logging.Interface Workdir internal.Workdir }
Helper methods for easily surfacing info in the TUI.
TODO: leverage a cache to enhance performance, particularly if we introduce sqlite at some stage. These helpers are invoked on every render, which for a table with, say 40 visible rows, means they are invoked 40 times a render, which is 40 lookups.
func (*Helpers) CostSummary ¶ added in v0.5.0
CostSummary renders a summary of the costs for a workspace.
func (*Helpers) CreateTasks ¶ added in v0.2.0
CreateTasks repeatedly invokes fn with each id in ids, creating a task for each invocation. If there is more than one id then a task group is created and the user sent to the task group's page; otherwise if only id is provided, the user is sent to the task's page.
func (*Helpers) CreateTasksWithSpecs ¶ added in v0.5.0
func (*Helpers) CurrentWorkspaceName ¶
func (*Helpers) GroupReport ¶ added in v0.2.0
GroupReport renders a colored summary of a task group's task statuses.
func (*Helpers) ModuleCost ¶ added in v0.5.0
ModuleCost renders the cost of the module's current workspace, if it has one.
func (*Helpers) ModuleCurrentResourceCount ¶ added in v0.1.10
func (*Helpers) ModuleCurrentWorkspace ¶ added in v0.2.0
func (*Helpers) ResourceReport ¶ added in v0.5.0
ResourceReport renders a colored summary of resource changes as a result of a plan or apply.
func (*Helpers) StateReloadReport ¶ added in v0.5.0
StateReloadReport renders a colored summary of changes resulting from a workspace reload.
func (*Helpers) TaskModule ¶ added in v0.5.2
func (*Helpers) TaskModulePath ¶ added in v0.5.2
func (*Helpers) TaskModulePathWithIcon ¶ added in v0.6.0
func (*Helpers) TaskStatus ¶ added in v0.2.0
TaskStatus provides a rendered colored task status.
func (*Helpers) TaskSummary ¶ added in v0.5.0
TaskSummary renders a summary of the task's outcome.
func (*Helpers) TaskWorkspace ¶ added in v0.2.0
TaskWorkspace retrieves the task's workspace if it belongs to one.
func (*Helpers) TaskWorkspaceName ¶ added in v0.5.2
func (*Helpers) TaskWorkspaceNameWithIcon ¶ added in v0.6.0
func (*Helpers) WorkspaceCost ¶ added in v0.5.0
WorkspaceCost renders the cost of the given workspace.
func (*Helpers) WorkspaceCurrentCheckmark ¶
WorkspaceCurrentCheckmark returns a check mark if the workspace is the current workspace for its module.
func (*Helpers) WorkspaceReloadReport ¶ added in v0.5.0
func (h *Helpers) WorkspaceReloadReport(report workspace.ReloadSummary, inherit lipgloss.Style) string
WorkspaceReloadReport renders a colored summary of workspaces added or removed as a result of a workspace reload.
type IDRetriever ¶ added in v0.6.0
type Maker ¶
type Maker interface {
Make(id resource.ID, width, height int) (ChildModel, error)
}
Maker makes new models
type ModelHelpBindings ¶
ModelHelpBindings is implemented by models that surface further help bindings specific to the model.
type NavigateOption ¶
type NavigateOption func(msg *NavigationMsg)
func DisableFocus ¶ added in v0.6.0
func DisableFocus() NavigateOption
func WithParent ¶
func WithParent(parent resource.ID) NavigateOption
func WithPosition ¶ added in v0.6.0
func WithPosition(position Position) NavigateOption
type NavigationMsg ¶
type NavigationMsg struct {}
NavigationMsg is an instruction to navigate to a page.
func NewNavigationMsg ¶
func NewNavigationMsg(kind Kind, opts ...NavigateOption) NavigationMsg
type Page ¶
type Page struct { // The model kind. Identifies the model maker to construct the page. Kind Kind // The ID of the resource for a model. In the case of global listings of // modules, workspaces, etc, this is the global resource. ID resource.ID }
Page identifies an instance of a model
type PaneManager ¶ added in v0.6.0
type PaneManager struct {
// contains filtered or unexported fields
}
PaneManager manages the layout of the three panes that compose the Pug full screen terminal app.
func NewPaneManager ¶ added in v0.6.0
func NewPaneManager(makers map[Kind]Maker) *PaneManager
NewPaneManager constructs the pane manager with at least the explorer, which occupies the left pane.
func (*PaneManager) FocusedModel ¶ added in v0.6.0
func (p *PaneManager) FocusedModel() ChildModel
FocusedModel retrieves the model of the focused pane.
func (*PaneManager) HelpBindings ¶ added in v0.6.0
func (m *PaneManager) HelpBindings() (bindings []key.Binding)
func (*PaneManager) Init ¶ added in v0.6.0
func (p *PaneManager) Init() tea.Cmd
func (*PaneManager) View ¶ added in v0.6.0
func (m *PaneManager) View() string
type Position ¶ added in v0.6.0
type Position int
const ( // TopRightPane occupies the top right area of the terminal. Mutually // exclusive with RightPane. TopRightPane Position = iota // BottomRightPane occupies the bottom right area of the terminal. Mutually // exclusive with RightPane. BottomRightPane // LeftPane occupies the left side of the terminal. LeftPane )
type Prompt ¶ added in v0.1.10
type Prompt struct {
// contains filtered or unexported fields
}
Prompt is a widget that prompts the user for input and triggers an action.
func (*Prompt) HandleBlink ¶ added in v0.1.10
HandleBlink handles the bubbletea blink message.
func (*Prompt) HandleKey ¶ added in v0.1.10
HandleKey handles the user key press, and returns a command to be run, and whether the prompt should be closed.
func (*Prompt) HelpBindings ¶ added in v0.1.10
type PromptAction ¶ added in v0.1.10
type PromptMsg ¶ added in v0.1.10
type PromptMsg struct { // Prompt to display to the user. Prompt string // Set initial value for the user to edit. InitialValue string // Action to carry out when key is pressed. Action PromptAction // Key that when pressed triggers the action and closes the prompt. Key key.Binding // Cancel is a key that when pressed skips the action and closes the prompt. Cancel key.Binding // CancelAnyOther, if true, checks if any key other than that specified in // Key is pressed. If so then the action is skipped and the prompt is // closed. Overrides Cancel key binding. CancelAnyOther bool // Set placeholder text in prompt Placeholder string }
PromptMsg enables the prompt widget.
type Viewport ¶ added in v0.2.0
type Viewport struct {
// contains filtered or unexported fields
}
Viewport is a wrapper of the upstream viewport bubble.
func NewViewport ¶ added in v0.2.0
func NewViewport(opts ViewportOptions) Viewport