internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProgressBar

func ProgressBar(percentage float64, baseStyle lipgloss.Style) string

ProgressBar creates a visual representation of a percentage as a progress bar.

Types

type LiveStatsFetcher

type LiveStatsFetcher struct{}

LiveStatsFetcher is the production implementation of StatsFetcher that uses gopsutil.

func (LiveStatsFetcher) CpuUsage

func (l LiveStatsFetcher) CpuUsage() (*cpu.TimesStat, error)

func (LiveStatsFetcher) HostInfo

func (l LiveStatsFetcher) HostInfo() (*host.InfoStat, error)

func (LiveStatsFetcher) LoadAvg

func (l LiveStatsFetcher) LoadAvg() (*load.AvgStat, error)

func (LiveStatsFetcher) MemUsage

func (l LiveStatsFetcher) MemUsage() (*mem.VirtualMemoryStat, error)

func (LiveStatsFetcher) SwapUsage

func (l LiveStatsFetcher) SwapUsage() (*mem.SwapMemoryStat, error)

type Model

type Model struct {
	HostInfo  *host.InfoStat
	CpuUsage  *cpu.TimesStat
	MemUsage  *mem.VirtualMemoryStat
	SwapUsage *mem.SwapMemoryStat
	LoadAvg   *load.AvgStat
	// contains filtered or unexported fields
}

func NewModel

func NewModel(refreshInterval time.Duration, fetcher StatsFetcher) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

func (Model) ViewHeader

func (m Model) ViewHeader() string

ViewHeader renders the header section with CPU and Memory usage

func (Model) ViewProcess

func (m Model) ViewProcess() string

type ProcessInfo

type ProcessInfo struct {
	PID           int32
	ParentPID     int32
	Name          string
	Username      string
	CPUPercent    float64
	MemoryPercent float32
	MemoryUsage   float64
	RunningTime   string
}

func GetProcess

func GetProcess() ([]ProcessInfo, error)

type StatsFetcher

type StatsFetcher interface {
	HostInfo() (*host.InfoStat, error)
	CpuUsage() (*cpu.TimesStat, error)
	MemUsage() (*mem.VirtualMemoryStat, error)
	SwapUsage() (*mem.SwapMemoryStat, error)
	LoadAvg() (*load.AvgStat, error)
}

StatsFetcher defines the interface for fetching system statistics. This allows us to use a real implementation in production and a mock for testing.

type TickMsg

type TickMsg time.Time

Jump to

Keyboard shortcuts

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