tui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOverallStatusIcon added in v0.1.0

func GetOverallStatusIcon(status OverallSyncStatus) string

GetOverallStatusIcon returns an icon for the overall status

func GetStatusIcon added in v0.1.0

func GetStatusIcon(status ServiceStatus, hasInCaddy bool) string

GetStatusIcon returns an icon representing the sync status

Types

type KeyMap

type KeyMap struct {
	Up     key.Binding
	Down   key.Binding
	Add    key.Binding
	Edit   key.Binding
	Delete key.Binding
	Apply  key.Binding
	Quit   key.Binding
	Help   key.Binding
}

KeyMap defines the keybindings for the TUI

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default keybindings

func (KeyMap) FullHelp

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

FullHelp returns the full set of keybindings

func (KeyMap) ShortHelp

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

ShortHelp returns keybinding help

type Model

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

Model represents the state of the TUI application

func NewModel

func NewModel(client *api.Client) Model

NewModel creates a new TUI model

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the TUI model

func (Model) Start

func (m Model) Start() error

Start initializes and runs the TUI

func (Model) Update

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

Update handles user input and updates the model

func (Model) View

func (m Model) View() string

View renders the TUI

type OverallSyncStatus added in v0.1.0

type OverallSyncStatus int

OverallSyncStatus represents the overall sync state

const (
	FullyInSync OverallSyncStatus = iota
	PartiallyInSync
	OutOfSync
	CaddyOnly
)

type ServiceStatus added in v0.1.0

type ServiceStatus struct {
	Present     bool   // Is the entry present in this system?
	IP          string // What IP does it point to?
	Description string // Entry description
	UUID        string // UUID (for UnboundDNS)
	InSync      bool   // Does the IP match Caddy's IP?
}

ServiceStatus represents the status of a service in a particular DNS system

type StatusFilters added in v0.1.0

type StatusFilters struct {
	ShowOnlyOutOfSync bool
	ShowOnlyUnbound   bool
	ShowOnlyAdguard   bool
	HostnameFilter    string
}

StatusFilters defines filtering options for the dashboard

type StyleConfig

type StyleConfig struct {
	// General styles
	Header   lipgloss.Style
	Section  lipgloss.Style
	Title    lipgloss.Style
	Subtitle lipgloss.Style
	Normal   lipgloss.Style
	Bold     lipgloss.Style
	Dimmed   lipgloss.Style

	// Status styles
	Success lipgloss.Style
	Warning lipgloss.Style
	Error   lipgloss.Style
	Info    lipgloss.Style

	// Action styles
	Add    lipgloss.Style
	Update lipgloss.Style
	Remove lipgloss.Style
	Count  lipgloss.Style

	// Content styles
	Hostname    lipgloss.Style
	IP          lipgloss.Style
	Description lipgloss.Style
	DryRun      lipgloss.Style

	// Table styles
	TableStyles table.Styles
}

StyleConfig contains all the styles used in the application

func DefaultStyles

func DefaultStyles() StyleConfig

DefaultStyles returns the default style configuration

type SyncStatus added in v0.1.0

type SyncStatus struct {
	Hostname      string
	CaddyIP       string            // IP from Caddy config (source of truth)
	UnboundStatus ServiceStatus     // Status in UnboundDNS
	AdguardStatus ServiceStatus     // Status in AdguardHome
	Overall       OverallSyncStatus // Overall sync status
}

SyncStatus represents the sync status of a hostname across all systems

type SyncStatusDashboard added in v0.1.0

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

SyncStatusDashboard manages the 3-way sync status display

func NewSyncStatusDashboard added in v0.1.0

func NewSyncStatusDashboard() *SyncStatusDashboard

NewSyncStatusDashboard creates a new sync status dashboard

func (*SyncStatusDashboard) GetFilteredStatuses added in v0.1.0

func (d *SyncStatusDashboard) GetFilteredStatuses() []SyncStatus

GetFilteredStatuses returns statuses that match current filters

func (*SyncStatusDashboard) GetSummary added in v0.1.0

func (d *SyncStatusDashboard) GetSummary() SyncSummary

GetSummary returns a summary of the sync status

func (*SyncStatusDashboard) LoadSyncData added in v0.1.0

func (d *SyncStatusDashboard) LoadSyncData(
	caddyClient *api.CaddyClient,
	unboundClient *api.Client,
	adguardClient *api.AdguardClient,
) error

LoadSyncData fetches data from all three systems and builds the sync status

func (*SyncStatusDashboard) SetFilters added in v0.1.0

func (d *SyncStatusDashboard) SetFilters(filters StatusFilters)

SetFilters updates the current filters

type SyncStatusRenderer added in v0.1.0

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

SyncStatusRenderer handles the visual rendering of the sync status dashboard

func NewSyncStatusRenderer added in v0.1.0

func NewSyncStatusRenderer(dashboard *SyncStatusDashboard) *SyncStatusRenderer

NewSyncStatusRenderer creates a new renderer for the sync status dashboard

func (*SyncStatusRenderer) RenderCompactSummary added in v0.1.0

func (r *SyncStatusRenderer) RenderCompactSummary() string

RenderCompactSummary renders a one-line summary for quick status checks

func (*SyncStatusRenderer) RenderDashboard added in v0.1.0

func (r *SyncStatusRenderer) RenderDashboard() string

RenderDashboard renders the complete sync status dashboard

func (*SyncStatusRenderer) SetShowIPs added in v0.1.0

func (r *SyncStatusRenderer) SetShowIPs(show bool)

SetShowIPs controls whether to show IP addresses in the table

func (*SyncStatusRenderer) SetWidth added in v0.1.0

func (r *SyncStatusRenderer) SetWidth(width int)

SetWidth sets the rendering width

type SyncSummary added in v0.1.0

type SyncSummary struct {
	Total           int
	FullyInSync     int
	PartiallyInSync int
	OutOfSync       int
	CaddyOnly       int
	InCaddy         int
	InUnbound       int
	InAdguard       int
}

SyncSummary provides statistics about the sync status

type UI

type UI struct {
	Styles StyleConfig
}

UI provides common UI rendering functions for all commands

func NewUI

func NewUI() *UI

NewUI creates a new UI with default styles

func (*UI) RenderDescription

func (ui *UI) RenderDescription(description string) string

RenderDescription renders a description

func (*UI) RenderDryRun

func (ui *UI) RenderDryRun() string

RenderDryRun renders a dry run indicator

func (*UI) RenderError

func (ui *UI) RenderError(err error) string

RenderError renders an error message

func (*UI) RenderHostname

func (ui *UI) RenderHostname(hostname string) string

RenderHostname renders a hostname

func (*UI) RenderIP

func (ui *UI) RenderIP(ip string) string

RenderIP renders an IP address

func (*UI) RenderInfo

func (ui *UI) RenderInfo(message string) string

RenderInfo renders an info message

func (*UI) RenderKeyValue

func (ui *UI) RenderKeyValue(key, value string) string

RenderKeyValue renders a key-value pair

func (*UI) RenderSection

func (ui *UI) RenderSection(title string) string

RenderSection renders a section title

func (*UI) RenderSeparator

func (ui *UI) RenderSeparator() string

RenderSeparator renders a horizontal separator line

func (*UI) RenderSuccess

func (ui *UI) RenderSuccess(message string) string

RenderSuccess renders a success message

func (*UI) RenderTitle

func (ui *UI) RenderTitle(title string, emoji string) string

RenderTitle renders a title with optional emoji

func (*UI) RenderWarning

func (ui *UI) RenderWarning(message string) string

RenderWarning renders a warning message

Jump to

Keyboard shortcuts

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