curd

package module
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 12 Imported by: 2

README

Curd

curd

The glue that holds the cheese together. Shared TUI component library for swissgit, raclette, and fondue.

Status

Quality Gate Status Reliability Rating Security Rating Maintainability Rating Vulnerabilities Bugs

Components

Component Description
Palette Color scheme (accent, accentBright, secondary, gradient)
StyleSet Pre-computed lipgloss styles from a palette
MenuModel App menu with ASCII banner, tagline, selectable items
RepoSelectModel Multi-select repo picker with search and scroll
ProgressModel Task progress tracker with status indicators
ResultModel Success/fail summary renderer
HintBar Context-aware keybinding hints
KeyMap Standard key bindings

Each app has its own palette:

  • SwissgitPalette — magenta/cyan
  • RaclettePalette — yellow/red
  • FonduePalette — green/orange

Install

go get github.com/CheeziCrew/curd

Built With

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorBg       = lipgloss.Color("0")
	ColorRed      = lipgloss.Color("1")
	ColorGreen    = lipgloss.Color("2")
	ColorYellow   = lipgloss.Color("3")
	ColorBlue     = lipgloss.Color("4")
	ColorMagenta  = lipgloss.Color("5")
	ColorCyan     = lipgloss.Color("6")
	ColorFg       = lipgloss.Color("7")
	ColorGray     = lipgloss.Color("8")
	ColorBrRed    = lipgloss.Color("9")
	ColorBrGreen  = lipgloss.Color("10")
	ColorBrYellow = lipgloss.Color("11")
	ColorBrBlue   = lipgloss.Color("12")
	ColorBrMag    = lipgloss.Color("13")
	ColorBrCyan   = lipgloss.Color("14")
	ColorBrWhite  = lipgloss.Color("15")
)

Base16 ANSI colors — respects terminal theme (works with Tinty, base16 etc).

View Source
var (
	// SwissgitPalette — magenta/cyan theme.
	SwissgitPalette = Palette{
		Accent:       ColorMagenta,
		AccentBright: ColorBrMag,
		Secondary:    ColorBlue,
		LogoGradient: []color.Color{ColorBrMag, ColorMagenta, ColorBrBlue, ColorBlue},
	}

	// RaclettePalette — yellow/red theme.
	RaclettePalette = Palette{
		Accent:       ColorYellow,
		AccentBright: ColorBrYellow,
		Secondary:    ColorRed,
		LogoGradient: []color.Color{ColorBrYellow, ColorYellow, ColorBrRed, ColorRed},
	}

	// FonduePalette — green/orange theme (full cheese mode 🧀).
	FonduePalette = Palette{
		Accent:       ColorGreen,
		AccentBright: ColorBrGreen,
		Secondary:    ColorYellow,
		LogoGradient: []color.Color{ColorBrGreen, ColorGreen, ColorBrYellow, ColorYellow},
	}

	// GruyerePalette — cyan/blue theme.
	GruyerePalette = Palette{
		Accent:       ColorCyan,
		AccentBright: ColorBrCyan,
		Secondary:    ColorBlue,
		LogoGradient: []color.Color{ColorBrCyan, ColorCyan, ColorBrBlue, ColorBlue},
	}
)

Pre-built palettes for each app.

View Source
var DefaultKeyMap = KeyMap{
	Up:     key.NewBinding(key.WithKeys("up", "k"), key.WithHelp("↑/k", "up")),
	Down:   key.NewBinding(key.WithKeys("down", "j"), key.WithHelp("↓/j", "down")),
	Enter:  key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")),
	Back:   key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")),
	Quit:   key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")),
	Toggle: key.NewBinding(key.WithKeys("space"), key.WithHelp("space", "toggle")),
	All:    key.NewBinding(key.WithKeys("ctrl+a"), key.WithHelp("ctrl+a", "toggle all")),
	Tab:    key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "next field")),
}

DefaultKeyMap provides standard keybindings.

Functions

func IsBack

func IsBack(msg tea.KeyPressMsg) bool

func IsDown

func IsDown(msg tea.KeyPressMsg) bool

func IsEnter

func IsEnter(msg tea.KeyPressMsg) bool

func IsSelectAll

func IsSelectAll(msg tea.KeyPressMsg) bool

func IsToggle

func IsToggle(msg tea.KeyPressMsg) bool

func IsUp

func IsUp(msg tea.KeyPressMsg) bool

func NewStyledInput added in v0.2.8

func NewStyledInput(placeholder string, p Palette) textinput.Model

NewStyledInput creates a textinput with palette-consistent styling. Width defaults to 60 characters.

func RenderHintBar

func RenderHintBar(styles StyleSet, hints []Hint) string

RenderHintBar renders a styled hint bar from a list of hints. Keys are rendered in the palette's accent color, descriptions in normal text, separated by dimmed dots. The bar has a top border for visual separation.

func TruncateError

func TruncateError(err string, maxLen int) string

TruncateError trims long error messages, keeping the juicy tail.

Types

type AllTasksDoneMsg

type AllTasksDoneMsg struct{}

AllTasksDoneMsg is sent when all tasks have finished.

type BackToMenuMsg

type BackToMenuMsg struct{}

BackToMenuMsg signals the root model to return to the menu.

type ConfirmConfig added in v0.2.8

type ConfirmConfig struct {
	Question string // e.g. "Drop uncommitted changes?"
	Caller   string // passed through to ConfirmMsg
	Palette  Palette
}

ConfirmConfig configures the confirmation dialog.

type ConfirmModel added in v0.2.8

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

ConfirmModel is a yes/no confirmation dialog.

func NewConfirmModel added in v0.2.8

func NewConfirmModel(cfg ConfirmConfig) ConfirmModel

NewConfirmModel creates a confirmation dialog.

func (ConfirmModel) Init added in v0.2.8

func (m ConfirmModel) Init() tea.Cmd

func (ConfirmModel) Update added in v0.2.8

func (m ConfirmModel) Update(msg tea.Msg) (ConfirmModel, tea.Cmd)

func (ConfirmModel) View added in v0.2.8

func (m ConfirmModel) View() string

type ConfirmMsg added in v0.2.8

type ConfirmMsg struct {
	Confirmed bool
	Caller    string // optional context for routing in the parent
}

ConfirmMsg is sent when the user answers a yes/no confirmation prompt.

type FilterListConfig added in v0.2.8

type FilterListConfig struct {
	Items    []list.Item
	Delegate list.ItemDelegate
	Title    string
	Palette  Palette
	Width    int
	Height   int
}

FilterListConfig configures a filterable list.

type FilterListModel added in v0.2.8

type FilterListModel struct {
	List list.Model // exposed so apps can call List methods directly
	// contains filtered or unexported fields
}

FilterListModel wraps bubbles/list with palette-aware styling.

func NewFilterListModel added in v0.2.8

func NewFilterListModel(cfg FilterListConfig) FilterListModel

NewFilterListModel creates a palette-styled filterable list.

func (FilterListModel) Filtering added in v0.2.8

func (m FilterListModel) Filtering() bool

Filtering returns true if the user is currently typing a filter query.

func (FilterListModel) Init added in v0.2.8

func (m FilterListModel) Init() tea.Cmd

func (FilterListModel) SelectedItem added in v0.2.8

func (m FilterListModel) SelectedItem() list.Item

SelectedItem returns the currently highlighted item, or nil if the list is empty.

func (*FilterListModel) SetSize added in v0.2.8

func (m *FilterListModel) SetSize(w, h int)

SetSize updates the list dimensions.

func (FilterListModel) Update added in v0.2.8

func (m FilterListModel) Update(msg tea.Msg) (FilterListModel, tea.Cmd)

func (FilterListModel) View added in v0.2.8

func (m FilterListModel) View() string

type FlashClearMsg added in v0.2.8

type FlashClearMsg struct{}

FlashClearMsg is sent when a flash message should be cleared.

type FlashModel added in v0.2.8

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

FlashModel displays a timed notification message that auto-clears.

func NewFlashModel added in v0.2.8

func NewFlashModel(p Palette) FlashModel

NewFlashModel creates a flash notification tied to a palette.

func (FlashModel) Active added in v0.2.8

func (m FlashModel) Active() bool

Active returns true if a flash message is currently displayed.

func (FlashModel) Clear added in v0.2.8

func (m FlashModel) Clear() FlashModel

Clear removes the current flash message.

func (FlashModel) Show added in v0.2.8

func (m FlashModel) Show(message string, duration time.Duration) (FlashModel, tea.Cmd)

Show sets a success flash message and returns a cmd to clear it after duration.

func (FlashModel) ShowError added in v0.2.8

func (m FlashModel) ShowError(message string, duration time.Duration) (FlashModel, tea.Cmd)

ShowError sets an error flash message and returns a cmd to clear it after duration.

func (FlashModel) View added in v0.2.8

func (m FlashModel) View() string

View renders the flash message. Returns empty string if no message is active.

type Hint

type Hint struct {
	Key  string // Displayed key (e.g. "esc", "j/k", "enter")
	Desc string // What the key does (e.g. "back", "move", "select")
}

Hint represents a single key-description pair in a hint bar.

type KeyMap

type KeyMap struct {
	Up     key.Binding
	Down   key.Binding
	Enter  key.Binding
	Back   key.Binding
	Quit   key.Binding
	Toggle key.Binding
	All    key.Binding
	Tab    key.Binding
}

KeyMap defines shared keybindings across all swiss* apps.

type MenuConfig struct {
	Banner  []string // ASCII art lines for the logo
	Tagline string   // shown below logo
	Items   []MenuItem
	Palette Palette
}

MenuConfig configures the menu appearance.

type MenuItem struct {
	Icon    string
	Name    string
	Command string
	Desc    string
	Tag     string // optional tag like "[mvn]" shown between name and desc
}

MenuItem defines a single menu entry.

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

MenuModel is the shared main menu component.

func NewMenuModel

func NewMenuModel(cfg MenuConfig) MenuModel

NewMenuModel creates a menu from config.

func (m MenuModel) Init() tea.Cmd
func (m MenuModel) Update(msg tea.Msg) (MenuModel, tea.Cmd)
func (m MenuModel) View() string
type MenuSelectionMsg struct {
	Command string
}

MenuSelectionMsg is sent when the user picks a command from the menu.

type Palette

type Palette struct {
	// Primary accent (used for active items, borders, titles).
	Accent color.Color
	// Bright variant of accent.
	AccentBright color.Color
	// Secondary color (borders, subtle accents).
	Secondary color.Color
	// Gradient colors for the logo banner (top to bottom).
	LogoGradient []color.Color
}

Palette defines app-specific accent colors that give each tool its identity.

func (Palette) Styles

func (p Palette) Styles() StyleSet

Styles returns a StyleSet derived from the given palette. This is the single source of truth for all shared styles.

type ProgressModel

type ProgressModel struct {
	Tasks []RepoTask
	// contains filtered or unexported fields
}

ProgressModel shows a progress bar with a spinner for the current task.

func NewProgressModel

func NewProgressModel(tasks []RepoTask, palette Palette) ProgressModel

func (ProgressModel) Init

func (m ProgressModel) Init() tea.Cmd

func (ProgressModel) IsDone

func (m ProgressModel) IsDone() bool

func (ProgressModel) Update

func (m ProgressModel) Update(msg tea.Msg) (ProgressModel, tea.Cmd)

func (ProgressModel) View

func (m ProgressModel) View() string

type RepoInfo

type RepoInfo struct {
	Path          string
	Name          string
	Branch        string
	DefaultBranch string
	Modified      int
	Added         int
	Deleted       int
	Untracked     int
	Ahead         int
	Behind        int
	IsDirty       bool
}

RepoInfo holds metadata about a discovered repo.

type RepoSelectConfig

type RepoSelectConfig struct {
	Palette      Palette
	RootPath     string
	Caller       string // which screen requested the selection
	ParentOffset int    // lines consumed by parent screen
	TermHeight   int
	Scanner      ScanFunc
	SingleSelect bool // enter picks cursor item directly, no toggle/select-all
}

RepoSelectConfig configures the repo selector.

type RepoSelectDoneMsg

type RepoSelectDoneMsg struct {
	Paths  []string
	Caller string // which screen requested the selection
}

RepoSelectDoneMsg is sent when repos have been selected.

type RepoSelectModel

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

RepoSelectModel lets the user pick repos from discovered subdirectories.

func NewRepoSelectModel

func NewRepoSelectModel(cfg RepoSelectConfig) RepoSelectModel

NewRepoSelectModel creates a repo selector.

func (RepoSelectModel) Init

func (m RepoSelectModel) Init() tea.Cmd

func (RepoSelectModel) SelectedPaths

func (m RepoSelectModel) SelectedPaths() []string

SelectedPaths returns paths of all currently selected repos.

func (RepoSelectModel) Update

func (m RepoSelectModel) Update(msg tea.Msg) (RepoSelectModel, tea.Cmd)

func (RepoSelectModel) View

func (m RepoSelectModel) View() string

type RepoTask

type RepoTask struct {
	Name   string
	Path   string
	Status RepoTaskStatus
	Result string
	Error  string
}

RepoTask represents one repo being processed.

type RepoTaskStatus

type RepoTaskStatus int

RepoTaskStatus tracks the state of a single repo operation.

const (
	TaskPending RepoTaskStatus = iota
	TaskRunning
	TaskDone
	TaskFailed
)

type RepoTaskUpdateMsg

type RepoTaskUpdateMsg struct {
	Index  int
	Status RepoTaskStatus
	Result string
	Error  string
}

RepoTaskUpdateMsg is sent when a repo task completes.

type ResultModel

type ResultModel struct {
	Tasks []RepoTask
	Title string
	Width int
	// contains filtered or unexported fields
}

ResultModel displays a summary of completed operations.

func NewResultModel

func NewResultModel(title string, tasks []RepoTask, palette Palette) ResultModel

func (ResultModel) View

func (m ResultModel) View() string

type ScanFunc

type ScanFunc func(rootPath string) ([]RepoInfo, error)

ScanFunc is the scanning strategy. Apps provide their own. It runs in a goroutine and returns discovered repos.

type StyleSet

type StyleSet struct {
	// General
	Title      lipgloss.Style
	Subtitle   lipgloss.Style
	Help       lipgloss.Style
	HelpMargin lipgloss.Style
	Selected   lipgloss.Style
	Normal     lipgloss.Style
	Dim        lipgloss.Style
	InputBox   lipgloss.Style

	// Logo
	LogoBox lipgloss.Style
	Tagline lipgloss.Style
	Version lipgloss.Style

	// Menu
	MenuActiveItem   lipgloss.Style
	MenuInactiveItem lipgloss.Style
	MenuActiveName   lipgloss.Style
	MenuInactiveName lipgloss.Style
	MenuActiveDesc   lipgloss.Style
	MenuInactiveDesc lipgloss.Style

	// Checkmarks
	CursorMark   lipgloss.Style
	CheckStyle   lipgloss.Style
	UncheckStyle lipgloss.Style

	// Repo select
	RepoActiveItem     lipgloss.Style
	RepoInactiveItem   lipgloss.Style
	RepoCursorName     lipgloss.Style
	RepoSelectedName   lipgloss.Style
	RepoUnselectedName lipgloss.Style
	DirtyStyle         lipgloss.Style
	CleanMark          lipgloss.Style
	BranchMark         lipgloss.Style

	// Result / Progress
	SummaryBox   lipgloss.Style
	SuccessBox   lipgloss.Style
	FailBox      lipgloss.Style
	SuccessStyle lipgloss.Style
	FailStyle    lipgloss.Style
	PendingStyle lipgloss.Style
	ErrStyle     lipgloss.Style
	NameStyle    lipgloss.Style
	CountStyle   lipgloss.Style
	AccentStyle  lipgloss.Style
	ResultDim    lipgloss.Style
	ResultOk     lipgloss.Style
	ResultFail   lipgloss.Style
	ResultAccent lipgloss.Style
}

StyleSet holds all shared styles derived from a Palette.

Jump to

Keyboard shortcuts

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