ui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DocStyle = lipgloss.NewStyle().Margin(1, 2)
	NoStyle  = lipgloss.NewStyle()
)

Styles are derived from the theme.

View Source
var AvailableThemes = map[string]Theme{
	"ansi": {
		Primary:   lipgloss.Color("5"),
		Secondary: lipgloss.Color("6"),
		Error:     lipgloss.Color("1"),
		Warning:   lipgloss.Color("3"),
		Inactive:  lipgloss.Color("8"),
	},
	"mocha": {
		Primary:   lipgloss.Color("#fab387"),
		Secondary: lipgloss.Color("#89dceb"),
		Error:     lipgloss.Color("#f38ba8"),
		Warning:   lipgloss.Color("#f9e2af"),
		Inactive:  lipgloss.Color("#585b70"),
	},
	"nord": {
		Primary:   lipgloss.Color("#88C0D0"),
		Secondary: lipgloss.Color("#81A1C1"),
		Error:     lipgloss.Color("#BF616A"),
		Warning:   lipgloss.Color("#EBCB8B"),
		Inactive:  lipgloss.Color("#4C566A"),
	},
	"dracula": {
		Primary:   lipgloss.Color("#bd93f9"),
		Secondary: lipgloss.Color("#8be9fd"),
		Error:     lipgloss.Color("#ff5555"),
		Warning:   lipgloss.Color("#f1fa8c"),
		Inactive:  lipgloss.Color("#6272a4"),
	},
	"rose-pine": {
		Primary:   lipgloss.Color("#ebbcba"),
		Secondary: lipgloss.Color("#31748f"),
		Error:     lipgloss.Color("#eb6f92"),
		Warning:   lipgloss.Color("#f6c177"),
		Inactive:  lipgloss.Color("#908caa"),
	},
	"tokyo-night": {
		Primary:   lipgloss.Color("#7aa2f7"),
		Secondary: lipgloss.Color("#bb9af7"),
		Error:     lipgloss.Color("#f7768e"),
		Warning:   lipgloss.Color("#e0af68"),
		Inactive:  lipgloss.Color("#565f89"),
	},
	"gruvbox": {
		Primary:   lipgloss.Color("#fabd2f"),
		Secondary: lipgloss.Color("#83a598"),
		Error:     lipgloss.Color("#fb4934"),
		Warning:   lipgloss.Color("#fe8019"),
		Inactive:  lipgloss.Color("#928374"),
	},
	"everforest": {
		Primary:   lipgloss.Color("#a7c080"),
		Secondary: lipgloss.Color("#7fbbb3"),
		Error:     lipgloss.Color("#e67e80"),
		Warning:   lipgloss.Color("#dbbc7f"),
		Inactive:  lipgloss.Color("#859289"),
	},
}

AvailableThemes is a registry of all supported color schemes.

View Source
var DefaultTheme = AvailableThemes["ansi"]

DefaultTheme provides the fallback ANSI palette.

Functions

func DeleteRecord

func DeleteRecord(api *cloudflare.API, zoneID, recordID string, logger *log.Logger) tea.Cmd

DeleteRecord returns a tea.Cmd that deletes a DNS record.

func FetchRecords

func FetchRecords(api *cloudflare.API, zoneID string, logger *log.Logger) tea.Cmd

FetchRecords returns a tea.Cmd that fetches DNS records for a specific zone.

func FetchZones

func FetchZones(api *cloudflare.API, logger *log.Logger) tea.Cmd

FetchZones returns a tea.Cmd that fetches all Cloudflare zones.

func SaveRecord

func SaveRecord(api *cloudflare.API, zoneID string, f *RecordForm, logger *log.Logger) tea.Cmd

SaveRecord returns a tea.Cmd that saves (creates or updates) a DNS record.

Types

type ErrorMsg

type ErrorMsg error

type FetchedRecordsMsg

type FetchedRecordsMsg []cloudflare.DNSRecord

type FetchedZonesMsg

type FetchedZonesMsg []cloudflare.Zone

Message types for async operations.

type Model

type Model struct {
	State    SessionState
	CfClient *cloudflare.API
	Theme    Theme

	ZoneList   list.Model
	RecordList list.Model
	Form       RecordForm
	Spinner    spinner.Model
	Logger     *log.Logger
	LogFile    *os.File

	Err        error
	SelectedID string

	// Dimensions
	Width  int
	Height int

	// Confirmation info
	OldRecord         *cloudflare.DNSRecord
	PendingDeleteID   string
	PendingDeleteName string
}

Model represents the application state.

func InitialModel

func InitialModel(api *cloudflare.API, theme *Theme, logger *log.Logger, logFile *os.File) *Model

InitialModel returns the initial state of the application.

func (*Model) Close

func (m *Model) Close()

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) Update

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

func (*Model) View

func (m *Model) View() string

type RecordDeletedMsg

type RecordDeletedMsg struct{}

type RecordForm

type RecordForm struct {
	ID           string
	Type         string
	TypeList     list.Model
	Inputs       []textinput.Model
	Focused      int
	Proxied      bool
	Comment      string
	FlattenCNAME bool
}

RecordForm manages input fields for adding/editing a record.

func NewRecordForm

func NewRecordForm(r *cloudflare.DNSRecord, theme *Theme) RecordForm

NewRecordForm initializes a form for a DNS record.

type RecordItem

type RecordItem struct {
	DNS cloudflare.DNSRecord
}

RecordItem implements list.Item for the DNS Record view.

func (*RecordItem) Description

func (i *RecordItem) Description() string

func (*RecordItem) FilterValue

func (i *RecordItem) FilterValue() string

func (*RecordItem) Title

func (i *RecordItem) Title() string

type RecordSavedMsg

type RecordSavedMsg struct{}

type SessionState

type SessionState int

SessionState tracks which view is currently active.

const (
	LoadingZonesState SessionState = iota
	ZoneListState
	LoadingRecordsState
	RecordListState
	EditingRecordState
	PickingTypeState
	ConfirmingDeleteState
	ConfirmingSaveState
	ConfirmingQuitState
)

type Theme

type Theme struct {
	Primary   lipgloss.TerminalColor
	Secondary lipgloss.TerminalColor
	Error     lipgloss.TerminalColor
	Warning   lipgloss.TerminalColor
	Inactive  lipgloss.TerminalColor
}

Theme defines the color scheme for the application.

type ZoneItem

type ZoneItem struct {
	ID   string
	Name string
}

ZoneItem implements list.Item for the Zone Selection view.

func (*ZoneItem) Description

func (i *ZoneItem) Description() string

func (*ZoneItem) FilterValue

func (i *ZoneItem) FilterValue() string

func (*ZoneItem) Title

func (i *ZoneItem) Title() string

Jump to

Keyboard shortcuts

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