tui

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package tui provides a terminal user interface for guided remediation.

Index

Constants

View Source
const (
	ViewMinHeight = 20 // the minimum internal height the view can be
	ViewVPad      = 1  // the vertical padding of the view

	ViewMinWidth = 60  // the minimum internal width the view can be
	ViewWidthPct = 0.4 // percentage of terminal internal width the main view should occupy
	ViewHPad     = 2   // the horizontal padding of the view
)

View dimensions width / height refers to the internal text area of the view i.e. excluding the border and the padding

Variables

View Source
var (
	ColorPrimary  = lipgloss.Color("#e62129")                         // Red, from the OSV logo :)
	ColorDisabled = lipgloss.AdaptiveColor{Light: "250", Dark: "238"} // Grey
)
View Source
var (
	SelectedTextStyle = lipgloss.NewStyle().Foreground(ColorPrimary)
	DisabledTextStyle = lipgloss.NewStyle().Foreground(ColorDisabled)
)
View Source
var CloseViewModel tea.Cmd = func() tea.Msg { return ViewModelCloseMsg{} }
View Source
var Keys = KeyMap{
	Up: key.NewBinding(
		key.WithKeys("up"),
		key.WithHelp("↑", "move up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down"),
		key.WithHelp("↓", "move down"),
	),
	Left: key.NewBinding(
		key.WithKeys("left"),
	),
	Right: key.NewBinding(
		key.WithKeys("right"),
	),
	Select: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "select option"),
	),
	SwitchView: key.NewBinding(
		key.WithKeys("tab", "i"),
		key.WithHelp("i/tab", "switch views"),
	),
	Help: key.NewBinding(
		key.WithKeys("h"),
		key.WithHelp("h", "toggle help"),
	),
	Quit: key.NewBinding(
		key.WithKeys("q", "esc"),
		key.WithHelp("q/esc", "exit"),
	),
}

Functions

func NewInPlaceInfo

func NewInPlaceInfo(res remediation.InPlaceResult) *inPlaceInfo

func NewRelockInfo

func NewRelockInfo(change resolution.Difference) *relockInfo

func NewSpinner

func NewSpinner() spinner.Model

NewSpinner creates a stylised spinner

func NewVulnInfo

func NewVulnInfo(vuln *resolution.Vulnerability) *vulnInfo

func NewVulnList

func NewVulnList(vulns []*resolution.Vulnerability, preamble string) *vulnList

func RenderSelectorOption

func RenderSelectorOption(
	selected bool,
	cursor string,
	format string,
	args ...any,
) string

RenderSelectorOption provides an inline selector renderer, for layouts that don't fit neatly into a list/table

func RenderSeverity

func RenderSeverity(severities []*osvschema.Severity) string

func RenderSeverityShort

func RenderSeverityShort(severities []*osvschema.Severity) string

Types

type ChainGraph

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

func FindChainGraphs

func FindChainGraphs(subgraphs []*resolution.DependencySubgraph) []ChainGraph

FindChainGraphs constructs a graph of the shortest paths from each direct dependency to each unique vulnerable node

func (ChainGraph) String

func (c ChainGraph) String() string

type KeyMap

type KeyMap struct {
	Up         key.Binding
	Down       key.Binding
	Left       key.Binding
	Right      key.Binding
	Select     key.Binding
	SwitchView key.Binding
	Help       key.Binding
	Quit       key.Binding
}

func (KeyMap) FullHelp

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

func (KeyMap) ShortHelp

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

type ViewModel

type ViewModel interface {
	Update(msg tea.Msg) (ViewModel, tea.Cmd)
	View() string
	Resize(w, h int)
}

ViewModel provides a tea-like model for representing the secondary info panel which allows for resizing

type ViewModelCloseMsg

type ViewModelCloseMsg struct{}

ViewModelCloseMsg provides a message to close the ViewModel

Jump to

Keyboard shortcuts

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