app

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Overview

Package app is the root Bubble Tea model: layout, focus, key routing and asynchronous loading from providers.

Index

Constants

This section is empty.

Variables

View Source
var OpenActions = map[string]linkAction{"go": actGo, "copy": actCopy, "show": actShow}

OpenActions are what lazysecrets open --action takes, the Open link menu's choices that go there.

Functions

func OpenLink(r ref.Ref) tea.Msg

OpenLink is a message offering r in the Open link popup, for links handed over by the link handler (Program.Send).

Types

type Clipboard

type Clipboard interface {
	Write(s string) tea.Cmd
	Clear(fingerprint [32]byte) tea.Cmd
	// Read returns the clipboard's text, or an error where it can't be
	// read (over SSH).
	Read() (string, error)
}

Clipboard is implemented by clipboard.Clipboard.

type HandlerSetup

type HandlerSetup struct {
	Reason string // why links don't open lazysecrets
	// Install sets it up, returning what links open in ("kitty").
	Install func() (string, error)
}

HandlerSetup offers to set up the link handler.

type Model

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

func New

func New(providers []provider.Provider, opts Options) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Persist

func (m Model) Persist() error

Persist saves the cache and where lazysecrets was left; run it after the program ends.

func (Model) Update

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

func (Model) View

func (m Model) View() tea.View

type Options

type Options struct {
	// Timeout bounds every provider call. Defaults to 30s.
	Timeout time.Duration
	// Timeouts override Timeout for the providers of a kind.
	Timeouts map[provider.Kind]time.Duration
	// Icons shows Nerd Font glyphs next to backends.
	Icons bool
	// Clipboard defaults to the system clipboard, or OSC52 over SSH.
	Clipboard Clipboard
	// ClipboardClear clears copied values after this long; 0 disables.
	ClipboardClear time.Duration
	// OpenURL opens a web page; defaults to the system browser.
	OpenURL func(url string) error
	// ConfigFiles and StatePath are where lazysecrets reads its config
	// and keeps its state, for the status pane.
	ConfigFiles []string
	StatePath   string
	// Warning shows when the window opens: what lazysecrets skipped
	// instead of failing to start.
	Warning string
	// Changelog is CHANGELOG.md, for the status pane.
	Changelog string
	// CacheFile keeps what was loaded between runs; "" keeps it for this
	// run only.
	CacheFile string
	// ShareKey is the config's sharing.key: the secret that encrypts shared
	// env files, for repos whose .lazysecrets.yaml names none.
	ShareKey string
	// ShareRules are what a key's value must be to share with it.
	ShareRules share.Rules
	// Dir is the folder lazysecrets runs in: it goes back to where it was
	// left there, unless it was started on a link. "" doesn't.
	Dir string
	// FlatSources lists sources without provider groups.
	FlatSources bool
	// CollapseGroups starts with the Sources pane's groups folded, when
	// there are several.
	CollapseGroups bool
	// Store keeps stars, notes and the layout; defaults to an unsaved one.
	Store *store.Store
	// LoadDelay is how long the cursor must rest on a row before its
	// contents load (settled); 0 loads at once.
	LoadDelay time.Duration
	// ExpiryWarning marks items expiring within this long; 0 marks only
	// expired ones.
	ExpiryWarning time.Duration
	// RevealTimeout hides a revealed value after this long; 0 never.
	RevealTimeout time.Duration
	// HideOnBlur hides a revealed value when the terminal loses focus.
	HideOnBlur bool
	// OnActive is called on key presses and when the terminal gains
	// focus, so the link handler can pick the instance last used.
	OnActive func()
	// Version is shown at the bottom right ("0.1.0"); empty shows none.
	Version string
	// Commands are the custom commands from the config (commands.go).
	Commands []commands.Command
	// Keys, if set, replaces the default keymap (keys.Map.Apply).
	Keys *keys.Map
	// Updater, if set, finds and installs newer releases (U); with
	// UpdateCheck, lazysecrets also looks on its own at startup, at most
	// once per UpdateEvery (0 for a day).
	Updater     *Updater
	UpdateCheck bool
	UpdateEvery time.Duration
	// HandlerSetup, if set, offers to set up the link handler at startup.
	HandlerSetup *HandlerSetup
	// NoHistory stops counting uses of items for the Recent list.
	NoHistory bool
	// RecentIcon marks items used lately with ◷ in the lists
	// (ui.recentIcon).
	RecentIcon bool
	// Open is a reference to open at startup (lazysecrets open <ref>).
	Open *ref.Ref
	// OpenAction, if set, is what to do with Open, rather than asking:
	// go to it, and maybe copy or show its value (OpenActions). It ends in
	// the list, like Go to, rather than on the details.
	OpenAction string
	// Styles, if set, replaces the default theme (styles.FromTheme), and
	// DefaultFg the terminal's default text colour.
	Styles    *styles.Styles
	DefaultFg color.Color
}

Options configures the app.

type Updater

type Updater struct {
	Latest  func(context.Context) (update.Release, error)
	Install func(context.Context, update.Release) error
}

Updater finds and installs newer releases (internal/update).

Jump to

Keyboard shortcuts

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