bubble

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: EUPL-1.2 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Feint = lipgloss.AdaptiveColor{Light: "#333333", Dark: "#888888"}

	Color = lipgloss.AdaptiveColor{Light: "#111222", Dark: "#FAFAFA"}

	TextStyle  = lipgloss.NewStyle().Foreground(Color)
	FeintStyle = TextStyle.Copy().Foreground(Feint)
	BoldStyle  = TextStyle.Copy().Bold(true)
)
View Source
var (
	ErrNotCompleted = fmt.Errorf("this tasks is not completed")
)

Functions

func ChangeSetEntryToObjMetadataSet

func ChangeSetEntryToObjMetadataSet(entry ssa.ChangeSetEntry) object.ObjMetadataSet

func EntriesReady

func EntriesReady(changeSet *ssa.ChangeSet) int

func InstallCmd

func InstallCmd[T any](i *Installer[T]) tea.Cmd

func RemoveChangeSetEntry

func RemoveChangeSetEntry(entry ssa.ChangeSetEntry, changeSet *ssa.ChangeSet) *ssa.ChangeSet

func SetChangeSetEntry

func SetChangeSetEntry(entry ssa.ChangeSetEntry, changeSet *ssa.ChangeSet)

func ToUnstructured

func ToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)

func WaitCmd

func WaitCmd[T any](i *Installer[T], changeSetEntry ssa.ChangeSetEntry) tea.Cmd

Types

type BasicItem

type BasicItem struct {
	Name string
	Desc string
}

func (BasicItem) Description

func (i BasicItem) Description() string

func (BasicItem) FilterValue

func (i BasicItem) FilterValue() string

func (BasicItem) Title

func (i BasicItem) Title() string

type BasicItemList

type BasicItemList struct {
	List []BasicItem
}

func (BasicItemList) Items

func (i BasicItemList) Items() []list.Item

type ChoiceQuestion

type ChoiceQuestion[T any] struct {
	// contains filtered or unexported fields
}

func (ChoiceQuestion[T]) ID

func (i ChoiceQuestion[T]) ID() string

func (ChoiceQuestion[T]) Init

func (i ChoiceQuestion[T]) Init() tea.Cmd

Next returns the next question in the chain

func (ChoiceQuestion[T]) Next

func (i ChoiceQuestion[T]) Next(model T) string

Next returns the next question in the chain

func (ChoiceQuestion[T]) Render

func (i ChoiceQuestion[T]) Render(model T) string

Render renders the question.

func (ChoiceQuestion[T]) Result

func (i ChoiceQuestion[T]) Result(model T) (string, error)

func (ChoiceQuestion[T]) UpdateResult

func (i ChoiceQuestion[T]) UpdateResult(model T, value interface{}) error

func (ChoiceQuestion[T]) UpdateTea

func (i ChoiceQuestion[T]) UpdateTea(model T, msg tea.Msg) (Task[T], tea.Cmd)

UpdateTea updates the model T via Bubbletea UI

type ChoiceQuestionOpts

type ChoiceQuestionOpts[T any] struct {
	TaskOpts[T]

	Prompt string

	// OffsetY represents the list offset from the Y position.
	PaddingY int

	// ItemGetter returns all available items to the list
	// items on each render of the list.
	//
	// This is required.
	ItemGetter ItemGetter
	//	Items []list.Item
	// TeaState allows overriding the list.Model used to render the list, if desired.
	//
	// This is an optional field.  It is a pointer, and can be mutated outside
	// of the Tea framework.
	TeaState *list.Model

	// Render optionally handles rendering the text list manually.
	Render func(model T, textinput list.Model) string
}

type CreatedEntry

type CreatedEntry struct {
	Entry *ssa.ChangeSetEntry
}

type Foo

type Foo[T any] interface {
}

type InputQuestionOpts

type InputQuestionOpts[T any] struct {
	TaskOpts[T]

	Prompt      string
	Placeholder string

	// Render optionally handles rendering the text input manually.
	Render func(model T, textinput textinput.Model) string

	// TeaState allows overriding the textinput.Model used to render the
	// text input.
	//
	// This is an optional field.
	TeaState *textinput.Model
}

type Installer

type Installer[T any] struct {
	// contains filtered or unexported fields
}

func (Installer[T]) ID

func (i Installer[T]) ID() string

func (Installer[T]) Init

func (i Installer[T]) Init() tea.Cmd

func (Installer[T]) Initialized

func (i Installer[T]) Initialized() bool

func (Installer[T]) Next

func (i Installer[T]) Next(model T) string

Next returns the next question in the chain

func (Installer[T]) Render

func (i Installer[T]) Render(model T) string

Render renders the question.

func (Installer[T]) Result

func (i Installer[T]) Result(model T) (string, error)

func (Installer[T]) UpdateResult

func (i Installer[T]) UpdateResult(model T, value interface{}) error

func (*Installer[T]) UpdateTea

func (i *Installer[T]) UpdateTea(model T, msg tea.Msg) (Task[T], tea.Cmd)

UpdateTea updates the model T via Bubbletea UI

type InstallerOpts

type InstallerOpts[T any] struct {
	TaskOpts[T]

	Prompt string

	Components []component.Component

	Manager *ssa.ResourceManager
}

type InstructionOpts

type InstructionOpts[T any] struct {
	TaskOpts[T]

	Text string
}

type ItemGetter

type ItemGetter interface {
	Items() []list.Item
}

type ItemList

type ItemList struct {
	List []SelectItem
}

func (ItemList) Items

func (i ItemList) Items() []SelectItem

type Program

type Program[T any] interface {
	Intro(T) string

	Root() Stage[T]

	// Task returns a task by ID
	Stage(id string) Stage[T]

	Complete() (bool, error)
}

type ReadyEntry

type ReadyEntry struct {
	Entry *ssa.ChangeSetEntry
}

type SelectItem

type SelectItem struct {
	Name   string
	Desc   string
	Chosen bool
}

func (SelectItem) Description

func (i SelectItem) Description() string

func (SelectItem) FilterValue

func (i SelectItem) FilterValue() string

func (SelectItem) Title

func (i SelectItem) Title() string

type SelectItemGetter

type SelectItemGetter interface {
	Items() []SelectItem
}

type SelectQuestion

type SelectQuestion[T any] struct {
	// contains filtered or unexported fields
}

func (SelectQuestion[T]) ID

func (i SelectQuestion[T]) ID() string

func (SelectQuestion[T]) Init

func (i SelectQuestion[T]) Init() tea.Cmd

Next returns the next question in the chain

func (SelectQuestion[T]) Next

func (i SelectQuestion[T]) Next(model T) string

Next returns the next question in the chain

func (SelectQuestion[T]) Render

func (i SelectQuestion[T]) Render(model T) string

Render renders the question.

func (SelectQuestion[T]) Result

func (i SelectQuestion[T]) Result(model T) (string, error)

func (SelectQuestion[T]) UpdateResult

func (i SelectQuestion[T]) UpdateResult(model T, value interface{}) error

func (SelectQuestion[T]) UpdateTea

func (i SelectQuestion[T]) UpdateTea(model T, msg tea.Msg) (Task[T], tea.Cmd)

UpdateTea updates the model T via Bubbletea UI

type SelectQuestionOpts

type SelectQuestionOpts[T any] struct {
	TaskOpts[T]

	Cursor int

	Prompt string

	MultiSelect bool

	// OffsetY represents the list offset from the Y position.
	PaddingY int

	// ItemGetter returns all available items to the list
	// items on each render of the list.
	//
	// This is required.
	ItemGetter SelectItemGetter

	// TeaState allows overriding the list.Model used to render the list, if desired.
	//
	// This is an optional field.  It is a pointer, and can be mutated outside
	// of the Tea framework.
	TeaState *list.Model

	// Render optionally handles rendering the text list manually.
	Render func(model T, textinput list.Model) string
}

type Stage

type Stage[T any] struct {
	StageOpts[T]

	// Model represents the model that this stage updates.
	Model T
	// contains filtered or unexported fields
}

func NewProgram

func NewProgram[T any](model T, opts StageOpts[T]) (*Stage[T], error)

func NewStage

func NewStage[T any](model T, opts StageOpts[T]) (*Stage[T], error)

func (*Stage[T]) Complete

func (s *Stage[T]) Complete() (bool, error)

func (*Stage[T]) ID

func (s *Stage[T]) ID() string

func (*Stage[T]) Init

func (s *Stage[T]) Init() tea.Cmd

func (*Stage[T]) Root

func (s *Stage[T]) Root() Task[T]

func (Stage[T]) Task

func (s Stage[T]) Task(id string) Task[T]

Task returns a step by ID

func (*Stage[T]) Update

func (s *Stage[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Stage[T]) View

func (s Stage[T]) View() string

type StageOpts

type StageOpts[T any] struct {
	Tasks  []Task[T]
	RootID string

	// Intro renders an intro to the stage.
	Intro func(T) string

	ID string
	// Spinner spinner.Model
	TaskOpts[T]
}

type Task

type Task[T any] interface {
	// ID allows us to reference tasks, eg. for setting the root
	ID() string

	// Result returns the result as a string.  If the tasks is
	// not completed, this must return the error ErrNotCompleted.
	Result(T) (string, error)

	// Render renders the tasks.
	Render(T) string

	// UpdateTea updates the model T via Bubbletea UI, returning any
	// commands necessary to re-render the state.
	UpdateTea(model T, msg tea.Msg) (Task[T], tea.Cmd)

	// UpdateResult is called when the qestion is completed.
	UpdateResult(model T, answer interface{}) error

	// Next returns the next tasks in the chain
	Next(T) string

	Init() tea.Cmd
}

func NewChoiceQuestion

func NewChoiceQuestion[T any](id string, opts ChoiceQuestionOpts[T]) Task[T]

func NewInputQuestion

func NewInputQuestion[T any](id string, opts InputQuestionOpts[T]) Task[T]

func NewInstaller

func NewInstaller[T any](id string, opts InstallerOpts[T]) Task[T]

func NewInstruction

func NewInstruction[T any](id string, opts InstructionOpts[T]) Task[T]

func NewSelectQuestion

func NewSelectQuestion[T any](id string, opts SelectQuestionOpts[T]) Task[T]

func NewTask

func NewTask[T any](id string, opts TaskOpts[T], render func(T) string) Task[T]

NewTask returns a task that custom-renders everything with no base.

func NewTextAreaQuestion

func NewTextAreaQuestion[T any](id string, opts TextAreaQuestionOpts[T]) Task[T]

type TaskOpts

type TaskOpts[T any] struct {
	// Result returns the current result as a string for display, or
	// ErrNotCompleted if this tasks has no result.
	Result func(T) (string, error)

	// UpdateResult is called with the answer from the tasks to
	// update the model.
	//
	// This must return a custom error if the result is invalid,
	// or ErrNotCompleted if there's no result.
	UpdateResult func(T, interface{}) error

	// Next returns the ID of the next tasks in the chain, if applicable.
	Next func(T) string

	// UpdateTea is called when receing a tea.Msg to update any internal
	// tea models.
	UpdateTea func(model T, msg tea.Msg) (Task[T], tea.Cmd)
}

type TextAreaQuestionOpts

type TextAreaQuestionOpts[T any] struct {
	TaskOpts[T]

	Prompt      string
	Placeholder string

	// Render optionally handles rendering the text textArea manually.
	Render func(model T, textArea textarea.Model) string

	// TeaState allows overriding the textArea.Model used to render the
	// text input.
	//
	// This is an optional field.
	TeaState *textarea.Model
}

Jump to

Keyboard shortcuts

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