tui

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 37 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run added in v0.13.0

func Run(ctx context.Context, model *Model, input *os.File, output io.Writer) (retErr error)

Run owns terminal input through shutdown and every SSH/unlock handoff. Input is borrowed; only its cancellable duplicate is closed. A nil input selects stdin or opens the controlling terminal when stdin is redirected.

Types

type CPUTicks added in v0.15.0

type CPUTicks struct {
	User    uint64 `json:"user"`
	Nice    uint64 `json:"nice"`
	Sys     uint64 `json:"sys"`
	Idle    uint64 `json:"idle"`
	Iowait  uint64 `json:"iowait"`
	Irq     uint64 `json:"irq"`
	Softirq uint64 `json:"softirq"`
	Steal   uint64 `json:"steal"`
}

func (*CPUTicks) IdleTicks added in v0.15.0

func (t *CPUTicks) IdleTicks() uint64

func (*CPUTicks) Total added in v0.15.0

func (t *CPUTicks) Total() uint64

type DiskMetric added in v0.15.0

type DiskMetric struct {
	MountPoint string
	Total      uint64 // MB
	Used       uint64 // MB
	Usage      float64
}

DiskMetric 存储单个分区的指标

type MetricsCollector added in v0.15.0

type MetricsCollector struct {
	SortBy  string // "cpu", "mem"
	SortAsc bool
	// contains filtered or unexported fields
}

func NewMetricsCollector added in v0.15.0

func NewMetricsCollector(c *ssh.Client) *MetricsCollector

func (*MetricsCollector) Close added in v0.15.0

func (mc *MetricsCollector) Close() error

func (*MetricsCollector) NextFrame added in v0.15.0

func (mc *MetricsCollector) NextFrame(ctx context.Context) (*SystemMetrics, error)

func (*MetricsCollector) SortConfig added in v0.15.0

func (mc *MetricsCollector) SortConfig() (string, bool)

SortConfig returns a stable snapshot of display ordering preferences.

func (*MetricsCollector) Start added in v0.15.0

func (mc *MetricsCollector) Start(ctx context.Context) error

func (*MetricsCollector) ToggleSortBy added in v0.15.0

func (mc *MetricsCollector) ToggleSortBy()

ToggleSortBy switches the display ordering without racing an in-flight frame decode.

func (*MetricsCollector) ToggleSortOrder added in v0.15.0

func (mc *MetricsCollector) ToggleSortOrder()

ToggleSortOrder reverses the display ordering without racing an in-flight frame decode.

type Model

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

func NewModel

func NewModel(repository *config.Repository, opts ...ModelOption) (Model, error)

NewModel initializes the TUI model. Package components use a no-op logger unless the CLI composition root explicitly supplies one with WithLogger.

func (*Model) Close added in v0.12.0

func (m *Model) Close() error

Close releases all TUI-owned streams and pooled SSH connections.

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) Update

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

func (Model) View

func (m Model) View() tea.View

type ModelOption added in v0.12.0

type ModelOption func(*modelConfig)

ModelOption configures dependencies used by a TUI model.

func WithContext added in v0.12.0

func WithContext(ctx context.Context) ModelOption

WithContext injects the lifetime context for TUI-owned I/O and goroutines.

func WithCredentialPersistenceUnavailable added in v0.12.0

func WithCredentialPersistenceUnavailable(unavailable bool) ModelOption

WithCredentialPersistenceUnavailable keeps connections usable when the CLI cannot initialize automatic saving. Explicit credential edits still fail.

func WithCredentialRegistry added in v0.12.0

func WithCredentialRegistry(reg *credential.Registry) ModelOption

WithCredentialRegistry injects the credential registry used to resolve stored secrets for SSH.

func WithCredentialService added in v0.12.0

func WithCredentialService(svc *credential.Service) ModelOption

WithCredentialService injects the credential service used for secure secret management.

func WithInteractionHandler added in v0.12.0

func WithInteractionHandler(interaction ssh.InteractionHandler) ModelOption

WithInteractionHandler injects SSH prompts run while Bubble Tea has released its terminal. Handlers must not wait on the paused TUI event loop.

func WithLogger added in v0.12.0

func WithLogger(l corelog.DebugLogger) ModelOption

WithLogger injects the debug logger used by TUI-owned package components.

func WithRememberConfirmation added in v0.12.0

func WithRememberConfirmation(confirm func(context.Context, string) (bool, error)) ModelOption

WithRememberConfirmation supplies the UI decision for remember_prompted: ask. Without a confirmer, ask remains session-only. The callback runs with the terminal released and must respect context cancellation.

func WithRememberPolicy added in v0.12.0

func WithRememberPolicy(policy string) ModelOption

WithRememberPolicy overrides automatic recording for this TUI invocation. Explicit credential form edits remain available under never.

func WithVaultControl added in v0.12.0

func WithVaultControl(control func(context.Context, bool) error) ModelOption

WithVaultControl injects process-local lock/unlock actions. Unlock runs with Bubble Tea's terminal released; no master password enters the model state.

type SystemMetrics added in v0.15.0

type SystemMetrics struct {
	CPUUsage     float64
	Cores        int
	MemTotal     uint64
	MemUsed      uint64
	MemUsage     float64
	Disks        []DiskMetric
	Uptime       string
	LoadAverage  string
	TopProcesses []string
}

SystemMetrics 给 TUI 展示用的整理后指标

Jump to

Keyboard shortcuts

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