tui

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tui provides the terminal user interface for DevSec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTerminalSize

func GetTerminalSize() (width, height int, err error)

GetTerminalSize returns the current terminal dimensions.

func IsTUIEnabled

func IsTUIEnabled(progressFlag bool) bool

IsTUIEnabled checks if TUI should be enabled based on environment.

func IsTerminal

func IsTerminal() bool

IsTerminal checks if stdout is a terminal.

func LogLevelStyle

func LogLevelStyle(level string) lipgloss.Style

LogLevelStyle returns the appropriate style for a log level.

func Run

func Run(m Model) error

Run starts the TUI with the given model.

func SeverityStyle

func SeverityStyle(severity string) lipgloss.Style

SeverityStyle returns the appropriate style for a severity level.

Types

type CommandType

type CommandType int

CommandType represents the type of command being executed.

const (
	// CommandTypePipeline is for pipeline commands.
	CommandTypePipeline CommandType = iota
	// CommandTypeScan is for scan commands.
	CommandTypeScan
	// CommandTypeCompliance is for compliance commands.
	CommandTypeCompliance
	// CommandTypeML is for ML commands.
	CommandTypeML
)

type Config

type Config struct {
	Events      <-chan progress.Event
	CommandName string
	Stages      []string
	CommandType CommandType
}

Config holds configuration for creating a new Model.

type KeyMap

type KeyMap struct {
	Quit       key.Binding
	ScrollUp   key.Binding
	ScrollDown key.Binding
	Help       key.Binding
}

KeyMap defines the key bindings for the TUI.

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.

func (KeyMap) ShortHelp

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

ShortHelp returns key bindings for the short help view.

type LogEntry

type LogEntry struct {
	Timestamp time.Time
	Level     string
	Message   string
}

LogEntry represents a log message.

type Model

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

Model is the main bubbletea model for the TUI.

func NewModel

func NewModel(cfg Config) Model

NewModel creates a new TUI model.

func (*Model) AddLog

func (m *Model) AddLog(level, message string)

AddLog adds a log entry.

func (*Model) AddStage

func (m *Model) AddStage(name string)

AddStage adds a new stage if it doesn't exist.

func (*Model) ElapsedTime

func (m *Model) ElapsedTime() time.Duration

ElapsedTime returns the elapsed time since start.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (*Model) IsComplete

func (m *Model) IsComplete() bool

IsComplete returns true if the operation has completed.

func (*Model) Result

func (m *Model) Result() (any, error)

Result returns the execution result and error.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets the terminal dimensions.

func (Model) Update

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

Update handles messages and updates the model.

func (*Model) UpdateStageStatus

func (m *Model) UpdateStageStatus(name string, status progress.StageStatus, duration time.Duration)

UpdateStageStatus updates the status of a stage.

func (Model) View

func (m Model) View() string

View renders the TUI.

type ProgressEventMsg

type ProgressEventMsg struct {
	Event progress.Event
}

ProgressEventMsg wraps a progress event for the bubbletea message loop.

type QuitMsg

type QuitMsg struct{}

QuitMsg indicates the user wants to quit.

type Stage

type Stage struct {
	Name     string
	Status   progress.StageStatus
	Duration time.Duration
}

Stage represents a pipeline stage with its status.

type Status

type Status int

Status represents the overall execution status.

const (
	// StatusIdle indicates waiting to start.
	StatusIdle Status = iota
	// StatusInProgress indicates currently running.
	StatusInProgress
	// StatusComplete indicates successfully completed.
	StatusComplete
	// StatusError indicates completed with errors.
	StatusError
)

type TickMsg

type TickMsg struct{}

TickMsg is sent on each tick for updating elapsed time and spinners.

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