updaters

package
v3.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package updaters contains the models that wrap the variable and provide the UI for changing their values.

Index

Constants

View Source
const ModelID = "updater"

Variables

View Source
var OnClose = CmdClose(ModelID)

OnClose defines the global command to close the program. It is set by default to CmdClose, but if running standalone, one must set it to tea.Quit, otherwise the program will not exit.

Functions

func CmdClose

func CmdClose(id string) func() tea.Msg

func CmdError

func CmdError(err error) tea.Msg

CmdError sends an error message.

func ValidateDuration

func ValidateDuration(s string) error

Types

type BoolModel

type BoolModel struct {
	Value *bool
}

BoolModel is a model for updating a boolean value. On startup, it sends a message to set the value to the opposite of the current value, and sends OnClose message. It has no view.

func NewBool

func NewBool(ptrBool *bool) BoolModel

func (BoolModel) Init

func (m BoolModel) Init() tea.Cmd

func (BoolModel) Update

func (m BoolModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (BoolModel) View

func (m BoolModel) View() string

type DateModel

type DateModel struct {
	Value *time.Time
	// contains filtered or unexported fields
}

func NewDTTM

func NewDTTM(ptrTime *time.Time) DateModel

func (DateModel) Init

func (m DateModel) Init() tea.Cmd

func (DateModel) Update

func (m DateModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (DateModel) View

func (m DateModel) View() string

type DurationModel

type DurationModel struct {
	Value *time.Duration
	// contains filtered or unexported fields
}

DurationModel is a model for updating a time.Duration value. It is a wrapper around a StringModel.

func NewDuration

func NewDuration(value *time.Duration, showPrompt bool) DurationModel

func (DurationModel) Init

func (m DurationModel) Init() tea.Cmd

func (DurationModel) Update

func (m DurationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (DurationModel) View

func (m DurationModel) View() string

type FileNewModel

type FileNewModel struct {
	// contains filtered or unexported fields
}

func NewFileNew

func NewFileNew(v *string, placeholder string, showPrompt bool, overwrite bool) FileNewModel

func (FileNewModel) Init

func (m FileNewModel) Init() tea.Cmd

func (FileNewModel) Update

func (m FileNewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FileNewModel) View

func (m FileNewModel) View() string

type FilepickModel

type FilepickModel struct {
	// contains filtered or unexported fields
}

func NewFilepickModel

func NewFilepickModel(ptrStr *string, f filemgr.Model, validateFn func(s string) error) FilepickModel

func (FilepickModel) Init

func (m FilepickModel) Init() tea.Cmd

func (FilepickModel) Update

func (m FilepickModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FilepickModel) View

func (m FilepickModel) View() string

type Model

type Model[T comparable] struct {
	// contains filtered or unexported fields
}

func NewPicklist

func NewPicklist[T comparable](v *T, s *huh.Select[T]) *Model[T]

func (*Model[T]) Init

func (m *Model[T]) Init() tea.Cmd

func (*Model[T]) Update

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

func (*Model[T]) View

func (m *Model[T]) View() string

type StringModel

type StringModel struct {
	Value *string
	// contains filtered or unexported fields
}

func NewString

func NewString(ptrStr *string, placeholder string, showPrompt bool, validateFn func(s string) error) StringModel

NewString creates a new stringUpdateModel

func (StringModel) Err

func (m StringModel) Err() error

func (StringModel) Init

func (m StringModel) Init() tea.Cmd

func (StringModel) Update

func (m StringModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (StringModel) View

func (m StringModel) View() string

type WMClose

type WMClose struct {
	// WndID is the window ID to close.  If empty, the current window
	// will be closed.
	WndID string
}

type WMError

type WMError error

WMError is sent when an error occurs, for example, a validation error, so that caller can display the error message.

Directories

Path Synopsis
examples
date command
filenew command
picklist command
string command
time command

Jump to

Keyboard shortcuts

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