Documentation ¶
Index ¶
- Constants
- Variables
- func Ago(now, t time.Time) string
- func CmdHandler(msg tea.Msg) tea.Cmd
- func GlobalBreadcrumb(title, total string) string
- func NavigateTo(kind Kind, opts ...NavigateOption) tea.Cmd
- func OpenVim(path string) tea.Cmd
- func RemoveDuplicateBindings(bindings []key.Binding) []key.Binding
- func ReportError(err error, msg string, args ...any) tea.Cmd
- func ReportInfo(msg string, args ...any) tea.Cmd
- func YesNoPrompt(prompt string, action tea.Cmd) tea.Cmd
- type ErrorMsg
- type FilterBlurMsg
- type FilterCloseMsg
- type FilterFocusAckMsg
- type FilterFocusReqMsg
- type FilterKeyMsg
- type Helpers
- func (h *Helpers) Breadcrumbs(title string, parent resource.Resource) string
- func (h *Helpers) CurrentWorkspaceName(workspaceID *resource.ID) string
- func (h *Helpers) LatestRunReport(r *run.Run) string
- func (h *Helpers) ModuleCurrentResourceCount(mod *module.Module) string
- func (h *Helpers) ModuleCurrentRunChanges(mod *module.Module) string
- func (h *Helpers) ModuleCurrentRunStatus(mod *module.Module) string
- func (h *Helpers) ModulePath(res resource.Resource) string
- func (h *Helpers) RunReport(report run.Report) string
- func (h *Helpers) RunStatus(r *run.Run) string
- func (h *Helpers) WorkspaceCurrentCheckmark(ws *workspace.Workspace) string
- func (h *Helpers) WorkspaceCurrentRunChanges(ws *workspace.Workspace) string
- func (h *Helpers) WorkspaceCurrentRunStatus(ws *workspace.Workspace) string
- func (h *Helpers) WorkspaceName(res resource.Resource) string
- func (h *Helpers) WorkspaceResourceCount(ws *workspace.Workspace) string
- type InfoMsg
- type Kind
- type Maker
- type ModelHelpBindings
- type ModelID
- type ModelStatus
- type ModelTitle
- type ModuleService
- type NavigateOption
- type NavigationMsg
- type Page
- type Prompt
- type PromptAction
- type PromptMsg
- type RunService
- type SetActiveTabMsg
- type StateService
- type Tab
- type TabSet
- func (m TabSet) Active() (bool, Tab)
- func (m TabSet) ActiveTitle() string
- func (m *TabSet) AddTab(maker Maker, parent resource.Resource, title string) (tea.Cmd, error)
- func (m *TabSet) HelpBindings() (bindings []key.Binding)
- func (m TabSet) Init() tea.Cmd
- func (m *TabSet) SetActiveTab(title string)
- func (m TabSet) Update(msg tea.Msg) (TabSet, tea.Cmd)
- func (m TabSet) View() string
- func (m TabSet) WithTabSetInfo(i tabSetInfo) TabSet
- type TaskService
- type WorkspaceService
Constants ¶
const ( Black = lipgloss.Color("#000000") DarkRed = lipgloss.Color("#FF0000") Red = lipgloss.Color("#FF5353") Pink = lipgloss.Color("#E760FC") Orange = lipgloss.Color("214") Yellow = lipgloss.Color("#DBBD70") Green = lipgloss.Color("34") LightGreen = lipgloss.Color("86") DarkGreen = lipgloss.Color("#325451") GreenBlue = lipgloss.Color("#00A095") DeepBlue = lipgloss.Color("39") LightBlue = lipgloss.Color("81") 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") )
const ( TasksTabTitle = "tasks" RunsTabTitle = "runs" )
Variables ¶
var ( DebugLogLevel = Blue InfoLogLevel = lipgloss.AdaptiveColor{Dark: string(LightGreen), Light: string(Green)} ErrorLogLevel = Red WarnLogLevel = Yellow LogRecordAttributeKey = lipgloss.AdaptiveColor{Dark: string(White), Light: string(Black)} HelpKey = Grey HelpDesc = LightGrey HighlightBackground = Grey HighlightForeground = White SelectedBackground = lipgloss.Color("#fcbbf0") SelectedForeground = Black HighlightedAndSelectedBackground = lipgloss.Color("#c997c0") HighlightedAndSelectedForeground = White TitleColor = lipgloss.AdaptiveColor{ Dark: "", Light: "", } ScrollPercentageBackground = lipgloss.AdaptiveColor{ Dark: string(DarkGrey), Light: string(EvenLighterGrey), } )
var ( Regular = lipgloss.NewStyle() Bold = Regular.Copy().Bold(true) Padded = Regular.Copy().Padding(0, 1) Faint = Regular.Copy().Faint(true) Width = lipgloss.Width Height = lipgloss.Height )
var ErrDuplicateTab = errors.New("not allowed to create tabs with duplicate titles")
var TitleStyle = Bold.Copy().Foreground(TitleColor)
Functions ¶
func GlobalBreadcrumb ¶
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 RemoveDuplicateBindings ¶ added in v0.1.4
RemoveDuplicateBindings removes duplicate bindings from a list of bindings. A binding is deemed a duplicate if another binding has the same list of keys.
Types ¶
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 FilterFocusAckMsg ¶ added in v0.1.9
type FilterFocusAckMsg struct{}
FilterFocusAckMsg acknowledges a request to focus the filter widget
type FilterFocusReqMsg ¶ added in v0.1.9
type FilterFocusReqMsg struct{}
FilterFocusReqMsg is a request to focus the filter widget. FilterFocusAckMsg should be sent in response to ackowledge the request.
type FilterKeyMsg ¶ added in v0.1.9
FilterKeyMsg is a key entered by the user into the filter widget
type Helpers ¶
type Helpers struct { ModuleService ModuleService WorkspaceService WorkspaceService RunService RunService StateService StateService Logger logging.Interface }
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) Breadcrumbs ¶
func (*Helpers) CurrentWorkspaceName ¶
func (*Helpers) ModuleCurrentResourceCount ¶ added in v0.1.10
func (*Helpers) ModuleCurrentRunChanges ¶
func (*Helpers) ModuleCurrentRunStatus ¶
func (*Helpers) WorkspaceCurrentCheckmark ¶
WorkspaceCurrentCheckmark returns a check mark if the workspace is the current workspace for its module.
func (*Helpers) WorkspaceCurrentRunChanges ¶
func (*Helpers) WorkspaceCurrentRunStatus ¶
type Kind ¶
type Kind int
func FirstPageKind ¶
FirstPageKind retrieves the model corresponding to the user requested first page.
type ModelHelpBindings ¶
ModelHelpBindings is implemented by models that surface further help bindings specific to the model.
type ModelID ¶
type ModelID interface {
ID() string
}
ModelID is implemented by models that are able to provide a unique identification string.
type ModelStatus ¶
type ModelStatus interface {
Status() string
}
ModelID is implemented by models that are able to provide a unique identification string.
type ModelTitle ¶
type ModelTitle interface {
Title() string
}
ModelTitle is implemented by models that show a title
type ModuleService ¶
type ModuleService interface { Get(id resource.ID) (*module.Module, error) List() []*module.Module Reload() ([]string, []string, error) Init(moduleID resource.ID) (*task.Task, error) Format(moduleID resource.ID) (*task.Task, error) Validate(moduleID resource.ID) (*task.Task, error) SetCurrent(moduleID, workspaceID resource.ID) error }
type NavigateOption ¶
type NavigateOption func(msg *NavigationMsg)
func WithParent ¶
func WithParent(parent resource.Resource) NavigateOption
func WithTab ¶ added in v0.1.11
func WithTab(tab string) 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 Kind Kind // The model's parent resource // // TODO: rename: it's sometimes a parent (in the case of listings), and // sometimes *the* resource. Parent resource.Resource }
Page identifies an instance of a model
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 }
PromptMsg enables the prompt widget.
type RunService ¶
type SetActiveTabMsg ¶
type SetActiveTabMsg string
type StateService ¶
type StateService interface { Reload(workspaceID resource.ID) (*task.Task, error) Get(workspaceID resource.ID) (*state.State, error) Delete(workspaceID resource.ID, addrs ...state.ResourceAddress) (*task.Task, error) Taint(workspaceID resource.ID, addr state.ResourceAddress) (*task.Task, error) Untaint(workspaceID resource.ID, addr state.ResourceAddress) (*task.Task, error) Move(workspaceID resource.ID, src, dest state.ResourceAddress) (*task.Task, error) }
type Tab ¶
A tab is one of a set of tabs. A tab has a title, and an embedded model, which is responsible for the visible content under the tab.
type TabSet ¶
type TabSet struct { Tabs []Tab // contains filtered or unexported fields }
TabSet is a related set of zero or more tabs, one of which is active, i.e. its contents are rendered.
func (TabSet) Active ¶
Active returns the currently active tab. If there are no tabs, then false is returned.
func (TabSet) ActiveTitle ¶
Active returns the title of the currently active tab. If there are no tabs, then an empty string is returned.
func (*TabSet) AddTab ¶
AddTab adds a tab to the tab set, using the maker and parent to construct the model associated with the tab. The title must be unique in the set. Upon success the associated model's Init() is returned for the caller to initialise the model.
func (*TabSet) HelpBindings ¶
func (*TabSet) SetActiveTab ¶
SetActiveTab looks up a tab with a title and makes it the active tab. If the tab's model is not yet initialized then its Init() command is returned. If no such tab exists no action is taken.