terminal

package
v0.0.0-...-515337b Latest Latest
Warning

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

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

Documentation

Overview

Package terminal provides colored output and progress display

Index

Constants

View Source
const (
	Reset     = "\033[0m"
	Bold      = "\033[1m"
	Dim       = "\033[2m"
	Red       = "\033[0;31m"
	Green     = "\033[0;32m"
	Yellow    = "\033[1;33m"
	Blue      = "\033[0;34m"
	Cyan      = "\033[0;36m"
	White     = "\033[0;37m"
	BoldRed   = "\033[1;31m"
	BoldGreen = "\033[1;32m"
)

ANSI color codes

View Source
const (
	IconSuccess = "✓"
	IconFailed  = "✗"
	IconRunning = "◐"
	IconQueued  = "○"
	IconSkipped = "⊘"
	IconWarning = "⚠"
	IconArrow   = "▸"
)

Icons for status display

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzerResultRow

type AnalyzerResultRow struct {
	Name     string
	Status   string // "success", "failed", "skipped"
	Summary  string
	Duration time.Duration
}

AnalyzerResultRow represents a row in the scanner results table

type ScanFindings

type ScanFindings struct {
	// Scanners that were run (used to conditionally show sections)
	ScannersRun map[string]bool

	// SBOM
	SBOMPath      string   // Path to generated SBOM file(s)
	SBOMPaths     []string // Multiple SBOM paths for multi-repo scans
	SBOMSizeTotal int64    // Total size of all SBOM files in bytes

	// Packages
	TotalPackages int
	PackagesByEco map[string]int

	// Vulnerabilities
	VulnCritical int
	VulnHigh     int
	VulnMedium   int
	VulnLow      int
	VulnsByEco   map[string]int

	// Licenses
	LicenseTypes  int
	LicenseCounts map[string]int

	// Secrets
	SecretsCritical int
	SecretsHigh     int
	SecretsMedium   int
	SecretsTotal    int

	// Malcontent
	MalcontentCrit int
	MalcontentHigh int

	// Health
	HealthCritical int
	HealthWarnings int

	// Tech-ID (Technology Detection)
	TechTotalTechs    int            // Total unique technologies detected
	TechByCategory    map[string]int // Technologies by category (language, framework, etc.)
	TechTopList       []string       // Top technologies across all repos
	TechMLModels      int            // ML models detected
	TechMLFrameworks  int            // AI/ML frameworks detected
	TechSecurityCount int            // Security findings from AI/ML analysis
}

ScanFindings holds aggregated scan findings

type Terminal

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

Terminal provides thread-safe terminal output

func New

func New() *Terminal

New creates a new Terminal instance

func (*Terminal) AnalyzerResultsTable

func (t *Terminal) AnalyzerResultsTable(rows []AnalyzerResultRow)

AnalyzerResultsTable prints a table of scanner results

func (*Terminal) AnalyzerRunning

func (t *Terminal) AnalyzerRunning(name string, estimate int)

AnalyzerRunning prints a running scanner line

func (*Terminal) Box

func (t *Terminal) Box(text string)

Box prints text in a decorative box

func (*Terminal) ClearLine

func (t *Terminal) ClearLine()

ClearLine clears the current line

func (*Terminal) Color

func (t *Terminal) Color(code, text string) string

Color wraps text in color codes if colors are enabled

func (*Terminal) Confirm

func (t *Terminal) Confirm(prompt string, defaultYes bool) bool

Confirm asks a yes/no question and returns the answer

func (*Terminal) Divider

func (t *Terminal) Divider()

Divider prints a horizontal line

func (*Terminal) Error

func (t *Terminal) Error(format string, args ...interface{})

Error prints an error message

func (*Terminal) Header

func (t *Terminal) Header(text string)

Header prints a section header

func (*Terminal) Info

func (t *Terminal) Info(format string, args ...interface{})

Info prints an info message

func (*Terminal) LogScannerStatus

func (t *Terminal) LogScannerStatus(name string, status string)

LogScannerStatus logs a scanner status message on a new line (doesn't update in place)

func (*Terminal) Progress

func (t *Terminal) Progress(completed, total int, active string)

Progress prints an in-place progress line (overwrites current line)

func (*Terminal) PromptChoice

func (t *Terminal) PromptChoice(prompt string, options []string, defaultOption int) int

PromptChoice asks user to select from options

func (*Terminal) RepoCloned

func (t *Terminal) RepoCloned(name, size, files, commit, status string)

RepoCloned prints a cloned repo result

func (*Terminal) RepoComplete

func (t *Terminal) RepoComplete(name string, success bool)

RepoComplete prints a completed repo header

func (*Terminal) RepoScanning

func (t *Terminal) RepoScanning(name string, estimate int)

RepoScanning prints a repo that's being scanned

func (*Terminal) ScanComplete

func (t *Terminal) ScanComplete()

ScanComplete prints the final scanning complete message

func (*Terminal) ScannerComplete

func (t *Terminal) ScannerComplete(name, summary string, duration int)

ScannerComplete prints a completed scanner result

func (*Terminal) ScannerFailed

func (t *Terminal) ScannerFailed(name, errMsg string, duration int)

ScannerFailed prints a failed scanner result

func (*Terminal) ScannerQueued

func (t *Terminal) ScannerQueued(name string, estimate int)

ScannerQueued prints a queued scanner line

func (*Terminal) ScannerSkipped

func (t *Terminal) ScannerSkipped(name string)

ScannerSkipped prints a skipped scanner line

func (*Terminal) SubHeader

func (t *Terminal) SubHeader(text string)

SubHeader prints a sub-section header

func (*Terminal) Success

func (t *Terminal) Success(format string, args ...interface{})

Success prints a success message

func (*Terminal) Summary

func (t *Terminal) Summary(org string, duration int, success, failed int, diskUsage, files string)

Summary prints the hydrate summary

func (*Terminal) SummaryWithFindings

func (t *Terminal) SummaryWithFindings(org string, duration int, success, failed int, diskUsage, files string, findings *ScanFindings)

SummaryWithFindings prints the hydrate summary with aggregated findings

func (*Terminal) UpdateScannerStatus

func (t *Terminal) UpdateScannerStatus(linesUp int, name string, status string, icon string, color string, extra string)

UpdateScannerStatus updates a scanner line in place (moves cursor up and rewrites)

func (*Terminal) Warn

func (t *Terminal) Warn(format string, args ...interface{})

Warn is an alias for Warning

func (*Terminal) Warning

func (t *Terminal) Warning(format string, args ...interface{})

Warning prints a warning message

Jump to

Keyboard shortcuts

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