ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ui owns terminal styling and shared interactive helpers.

The Python tool uses raw ANSI escape codes via a tiny Colors helper. We use lipgloss for the same effect but with adaptive colour, automatic NO_COLOR support, and proper width calculations for two-column layouts.

Index

Constants

This section is empty.

Variables

View Source
var (
	Title    = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12"))
	Heading  = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14"))
	Subtle   = lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
	Success  = lipgloss.NewStyle().Foreground(lipgloss.Color("10"))
	Warn     = lipgloss.NewStyle().Foreground(lipgloss.Color("11"))
	ErrorSty = lipgloss.NewStyle().Foreground(lipgloss.Color("9")).Bold(true)
	Accent   = lipgloss.NewStyle().Foreground(lipgloss.Color("13"))
	Favorite = lipgloss.NewStyle().Foreground(lipgloss.Color("11"))
	Muted    = lipgloss.NewStyle().Foreground(lipgloss.Color("244"))
)

Functions

func Errorf

func Errorf(msg string) string

func Iconf

func Iconf(style lipgloss.Style, glyph, msg string) string

Iconf prefixes a string with an indicator glyph styled in the given style.

func Infof

func Infof(msg string) string

func LoadVault

func LoadVault() (*store.Saved, error)

LoadVault is the canonical entry point for every command that touches the encrypted store. It tries (in order):

  1. an active session (no prompt)
  2. interactive password prompt
  3. first-time setup if no vault exists yet

On success, callers receive a *store.Saved they can mutate and re-save. The session is refreshed on every successful unlock.

func PromptNewPassword

func PromptNewPassword(title string) (string, error)

PromptNewPassword runs the same two-field flow as first-time setup. Used by `vault change-password`.

func PromptPassword

func PromptPassword(prompt string) (string, error)

PromptPassword does a one-shot password read (no confirmation). Used for legacy import where we need the OLD vault password.

func RenderServerTable

func RenderServerTable(servers []store.Server) string

RenderServerTable produces a sorted, numbered, lipgloss-styled table of servers. Auto-switches to two-column layout on terminals >= 140 columns, matching the Python tool's behaviour.

func Successf

func Successf(msg string) string

func TerminalWidth

func TerminalWidth() int

TerminalWidth returns the current terminal width, defaulting to 100 when stdout isn't a TTY (so piped output still wraps reasonably).

func Warnf

func Warnf(msg string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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