ui

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package ui provides an interactive terminal user interface for link checking. It uses the Bubble Tea framework to create a real-time TUI that displays scanning progress, check results, and allows filtering by link status.

Index

Constants

This section is empty.

Variables

View Source
var (
	PrimaryColor   = lipgloss.Color("205") // Pink
	SecondaryColor = lipgloss.Color("241") // Gray
	SuccessColor   = lipgloss.Color("82")  // Green
	ErrorColor     = lipgloss.Color("196") // Red
	WarningColor   = lipgloss.Color("214") // Orange
	BlockedColor   = lipgloss.Color("208") // Dark orange
	DuplicateColor = lipgloss.Color("139") // Purple/gray
	MutedColor     = lipgloss.Color("245") // Dimmed text
)

Color palette.

View Source
var (
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(PrimaryColor).
				MarginBottom(1)

	StatusStyle = lipgloss.NewStyle().
				Foreground(SecondaryColor)

	SuccessStyle = lipgloss.NewStyle().
					Foreground(SuccessColor)

	ErrorStyle = lipgloss.NewStyle().
				Foreground(ErrorColor)

	WarningStyle = lipgloss.NewStyle().
					Foreground(WarningColor)

	BlockedStyle = lipgloss.NewStyle().
					Foreground(BlockedColor)

	DuplicateStyle = lipgloss.NewStyle().
					Foreground(DuplicateColor)

	SelectedStyle = lipgloss.NewStyle().
					Foreground(PrimaryColor).
					Bold(true)

	NormalStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("252"))

	HelpStyle = lipgloss.NewStyle().
				Foreground(SecondaryColor).
				MarginTop(1)

	MutedStyle = lipgloss.NewStyle().
				Foreground(MutedColor)

	// Detail panel styles.
	DetailBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(SecondaryColor).
					Padding(0, 1).
					MarginTop(1)

	DetailLabelStyle = lipgloss.NewStyle().
						Foreground(SecondaryColor).
						Bold(true)

	DetailValueStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("252"))

	DetailNoteStyle = lipgloss.NewStyle().
					Foreground(MutedColor).
					Italic(true)
)

Text styles.

View Source
var (
	BadgeAlive = lipgloss.NewStyle().
				Foreground(lipgloss.Color("255")).
				Background(SuccessColor).
				Padding(0, 1).
				Bold(true)

	BadgeRedirect = lipgloss.NewStyle().
					Foreground(lipgloss.Color("0")).
					Background(WarningColor).
					Padding(0, 1).
					Bold(true)

	BadgeBlocked = lipgloss.NewStyle().
					Foreground(lipgloss.Color("255")).
					Background(BlockedColor).
					Padding(0, 1).
					Bold(true)

	BadgeDead = lipgloss.NewStyle().
				Foreground(lipgloss.Color("255")).
				Background(ErrorColor).
				Padding(0, 1).
				Bold(true)

	BadgeError = lipgloss.NewStyle().
				Foreground(lipgloss.Color("255")).
				Background(lipgloss.Color("161")).
				Padding(0, 1).
				Bold(true)

	BadgeDuplicate = lipgloss.NewStyle().
					Foreground(lipgloss.Color("255")).
					Background(DuplicateColor).
					Padding(0, 1).
					Bold(true)
)

Badge styles for status codes.

Functions

func ExtractLinksCmdWithRegistry added in v0.1.3

func ExtractLinksCmdWithRegistry(files []string, strictMode bool) tea.Cmd

ExtractLinksCmdWithRegistry extracts links from the given files using the parser registry.

func ScanFilesCmdWithOptions added in v0.1.3

func ScanFilesCmdWithOptions(path string, fileTypes, include, exclude []string) tea.Cmd

ScanFilesCmdWithOptions returns a command that scans for files using ScanOptions. This supports include/exclude glob patterns from the config file.

func SpinnerStyle

func SpinnerStyle() lipgloss.Style

SpinnerStyle returns the style for the spinner.

func StartCheckingCmd

func StartCheckingCmd(links []checker.Link, state *CheckerState) tea.Cmd

StartCheckingCmd initializes the checker and returns the first result.

func StatusBadge

func StatusBadge(status checker.LinkStatus) string

StatusBadge returns a styled badge for the given link status.

func StatusTextStyle

func StatusTextStyle(status checker.LinkStatus) lipgloss.Style

StatusTextStyle returns the appropriate style for a link status.

func SummaryAlive

func SummaryAlive(count int) string

SummaryAlive returns a styled count for alive links.

func SummaryDead

func SummaryDead(count int) string

SummaryDead returns a styled count for dead links.

func SummaryDuplicates

func SummaryDuplicates(count int) string

SummaryDuplicates returns a styled count for duplicate links.

func SummaryWarnings

func SummaryWarnings(count int) string

SummaryWarnings returns a styled count for warning links.

func WaitForNextResultCmd

func WaitForNextResultCmd(state *CheckerState) tea.Cmd

WaitForNextResultCmd waits for the next result from the channel.

Types

type AllChecksCompleteMsg

type AllChecksCompleteMsg struct{}

AllChecksCompleteMsg is sent when all link checks have finished.

type CheckerState

type CheckerState struct {
	ResultsChan <-chan checker.Result
	CancelFunc  context.CancelFunc
}

CheckerState holds the state needed for checking links. This allows the commands to be stateless functions.

type FilesFoundMsg

type FilesFoundMsg struct {
	Err   error
	Files []string
}

FilesFoundMsg is sent when markdown files have been discovered.

type KeyMap

type KeyMap struct {
	Up       key.Binding
	Down     key.Binding
	Filter   key.Binding
	Help     key.Binding
	Quit     key.Binding
	PageUp   key.Binding
	PageDown key.Binding
	Home     key.Binding
	End      key.Binding
}

KeyMap defines all key bindings for the application.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns key bindings for the full help view. Implements help.KeyMap interface.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns key bindings for the short help view. Implements help.KeyMap interface.

type LinkCheckedMsg

type LinkCheckedMsg struct {
	Result checker.Result
}

LinkCheckedMsg is sent when a single link has been checked.

type LinksExtractedMsg

type LinksExtractedMsg struct {
	Err        error
	Links      []checker.Link
	UniqueURLs int // Number of unique URLs to check
	Duplicates int // Number of duplicate occurrences
}

LinksExtractedMsg is sent when links have been extracted from files.

type Model

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

Model is the main application model.

func New

func New(
	path string, urlFilter *filter.Filter, fileTypes []string,
	strictMode bool, scanInclude, scanExclude []string,
) Model

New creates and returns a new Model for the given path. Optional filter can be passed to ignore certain URLs. fileTypes specifies which file types to scan (e.g., ["md", "json"]). strictMode causes parsing to fail on malformed files. scanInclude/scanExclude are optional glob patterns to filter files.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (Model) Update

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

Update handles messages and returns the updated model.

func (Model) View

func (m Model) View() string

View renders the UI.

type ResultItem

type ResultItem struct {
	Result checker.Result
}

ResultItem wraps a checker.Result to implement list.Item interface.

func ResultsToItems

func ResultsToItems(results []checker.Result) []ResultItem

ResultsToItems converts a slice of checker.Result to ResultItems.

func (ResultItem) Description

func (i ResultItem) Description() string

Description returns secondary text for the item. Implements list.DefaultItem interface.

func (ResultItem) DetailView

func (i ResultItem) DetailView() string

DetailView returns an expanded detail view for the selected item.

func (ResultItem) FilterValue

func (i ResultItem) FilterValue() string

FilterValue returns the string used for filtering. Implements list.Item interface.

func (ResultItem) Title

func (i ResultItem) Title() string

Title returns the main display text for the item. Implements list.DefaultItem interface.

type WindowSizeMsg

type WindowSizeMsg struct {
	Width  int
	Height int
}

WindowSizeMsg is sent when the terminal window size changes.

Jump to

Keyboard shortcuts

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