Documentation
¶
Index ¶
- func NewBaseStyle() lipgloss.Style
- type BubbleTea
- func (b *BubbleTea) AppendError(err error)
- func (b BubbleTea) BroadcastResult() error
- func (b BubbleTea) Error() error
- func (b BubbleTea) Init() tea.Cmd
- func (b BubbleTea) NextModel() Model
- func (b BubbleTea) Result() (*BubbleTeaResult, error)
- func (b *BubbleTea) ResultCallback(fn func(result *BubbleTeaResult) error) error
- func (b BubbleTea) Run(p RunParams) (*BubbleTeaResult, error)
- func (b BubbleTea) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (b *BubbleTea) UpdateModel(model Model) error
- func (b BubbleTea) View() string
- type BubbleTeaResult
- type ChoicesModel
- type ChoicesModelParams
- type ChoicesModelResult
- type ChoicesModelUI
- type ChoicesModelUIParams
- type Model
- type Models
- type Params
- type RunParams
- type TableHeader
- type TableModel
- type TableModelParams
- type TableModelResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBaseStyle ¶
NewBaseStyle returns the default lipgloss base style.
Types ¶
type BubbleTea ¶
type BubbleTea struct {
// contains filtered or unexported fields
}
BubbleTea represents the CLI component that wraps the `bubbletea` library.
func (*BubbleTea) AppendError ¶
`AppendError` appends the given error to the `BubbleTea` component slice of errors.
func (BubbleTea) BroadcastResult ¶
`BroadcastResult` broadcasts the results to the results callback.
func (BubbleTea) Init ¶
Init is the `BubbleTea` method required for implementing the `Model` interface.
func (BubbleTea) Result ¶
func (b BubbleTea) Result() (*BubbleTeaResult, error)
`Result` returns the `BubbleTea` component result.
func (*BubbleTea) ResultCallback ¶
func (b *BubbleTea) ResultCallback(fn func(result *BubbleTeaResult) error) error
`ResultCallback` sets the given function as a `BubbleTea` component resultCallback field.
func (BubbleTea) Run ¶
func (b BubbleTea) Run(p RunParams) (*BubbleTeaResult, error)
Run runs the `BubbleTea` component and returns its result.
func (BubbleTea) Update ¶
Update is the `BubbleTea` method required for implementing the `Model` interface. Returns the `BubbleTea` struct and the next tea command(In case of `nil`, it indicates that the bubbletea program continues to work).
func (*BubbleTea) UpdateModel ¶
UpdateModel updates `models` uses given model, the update is done by type.
type BubbleTeaResult ¶
type BubbleTeaResult struct {
// `ChoicesModelResult` is the result of the `ChoicesModel` component.
ChoicesModelResult *ChoicesModelResult
// `TableModelResult` is the result of the `TableModel` component.
TableModelResult *TableModelResult
}
`BubbleTeaResult` represents the `BubbleTea` component run result.
type ChoicesModel ¶
type ChoicesModel struct {
// contains filtered or unexported fields
}
ChoicesModel represents the CLI component that wraps the `bubbletea` library.
func NewChoicesModel ¶
func NewChoicesModel(p *ChoicesModelParams) *ChoicesModel
NewChoicesModel returns a pointer for the `ChoicesModel`.
func (ChoicesModel) Init ¶
func (b ChoicesModel) Init() tea.Cmd
Init is the `BubbleTea` method required for implementing the `Model` interface.
func (*ChoicesModel) Order ¶
func (b *ChoicesModel) Order() uint
func (ChoicesModel) Result ¶
func (b ChoicesModel) Result() any
`Result` returns the `ChoicesModel` component result.
func (*ChoicesModel) Update ¶
Update is the `BubbleTea` method required for implementing the `Model` interface.
func (ChoicesModel) View ¶
func (b ChoicesModel) View() string
View is the `BubbleTea` method required for implementing the `Model` interface.
func (*ChoicesModel) WithBaseStyle ¶
func (b *ChoicesModel) WithBaseStyle(baseStyle lipgloss.Style)
type ChoicesModelParams ¶
type ChoicesModelParams struct {
// Choice is the current CLI choice.
Choice string
// Choices is the slice of options available.
Choices []string
// Cursor is the reference of the current CLI choice.
Cursor int
// UI is the user interface parameters.
UI ChoicesModelUIParams
// BaseStyle is the base styling parameter of the BubbleTea component.
BaseStyle lipgloss.Style
// Order is the order parameter,
Order uint
}
ChoicesModelParams represents the parameters struct for the `NewChoicesModel` function.
type ChoicesModelResult ¶
type ChoicesModelResult struct {
// Choice is the option chosen.
Choice string
}
ChoicesModelResult represents the result of the run method.
type ChoicesModelUI ¶
type ChoicesModelUI struct {
// contains filtered or unexported fields
}
ChoicesModelUI represents the UI struct for the `ChoicesModel` component.
type ChoicesModelUIParams ¶
type ChoicesModelUIParams struct {
// Header is the UI header text.
Header string
}
ChoicesModelUIParams represents the UI parameters for the `NewChoicesModel` function parameters.
type Model ¶
type Model interface {
// Init initializes the model and returns the next tea command.
Init() tea.Cmd
// Update updates the model and returns the same model and the next tea command.
Update(msg tea.Msg) (Model, tea.Cmd)
// View returns the model view representation.
View() string
// Result returns the model result.
Result() any
// WithBaseStyle updates the model to use the given base style.
WithBaseStyle(baseStyle lipgloss.Style)
// Order returns the order of the model.
Order() uint
}
Model represents the component that wraps the `bubbletea` Model interface.
type Params ¶
type Params struct {
// Models are the models parameters for the `BubbleTea` component.
Models Models
// BaseStyle is the base styling parameter of the BubbleTea component.
BaseStyle lipgloss.Style
}
Params represents the parameters for the `NewBubbleTea` function.
type RunParams ¶
type RunParams struct {
// ResultCallback is the result callback Run parameter.
ResultCallback func(result *BubbleTeaResult) error
}
RunParams represents the Run parameters.
type TableHeader ¶
type TableHeader struct {
// Title is the title of the table header.
Title string
// Width is the styling width of the table header.
Width uint
}
TableHeader represents the table header.
type TableModel ¶
type TableModel struct {
// contains filtered or unexported fields
}
`TableModel` represents the component that implements the `Model` interface.
func NewTableModel ¶
func NewTableModel(p *TableModelParams) *TableModel
`NewTableModel` returns a pointer to a `TableModel`.
func (TableModel) Init ¶
func (tm TableModel) Init() tea.Cmd
`Init` is the `TableModel` method required for implementing the `Model` interface. Initializes the `TableModel` component and returns a `bubbletea` command.
func (*TableModel) Order ¶
func (tm *TableModel) Order() uint
func (TableModel) Result ¶
func (tm TableModel) Result() any
`Result` returns the `TableModel` component result.
func (*TableModel) Update ¶
`Update` is the `TableModel` method required for implementing the `Model` interface. Updates the `TableModel` component, handles the given message updating the internal state. Returns the current `TableModel` and the resolved command. TODO(@chris-ramon): Implement the `tea.Msg` handlers.
func (TableModel) View ¶
func (tm TableModel) View() string
`View` is the `TableModel` method required for implementing the `Model` interface. View renders the `TableModel` using the base style and returns the results.
func (*TableModel) WithBaseStyle ¶
func (tm *TableModel) WithBaseStyle(baseStyle lipgloss.Style)
`WithBaseStyle` updates the `TableModel` component to use the given base style.
type TableModelParams ¶
type TableModelParams struct {
// BaseStyle is the base styling parameter.
BaseStyle lipgloss.Style
// Order is the order parameter.
Order uint
// Headers are the slice of table headers.
Headers []TableHeader
// Rows are the slice of table rows.
Rows [][]string
}
`TableModelParams` represents the parameters component for the `NewTableModel` function.
type TableModelResult ¶
type TableModelResult struct {
}
`TableModelResult` represents the `TableModel` run method result.