rename item struct to menuItem
This commit is contained in:
parent
60f16c9205
commit
2f18893ef2
1 changed files with 14 additions and 14 deletions
|
|
@ -13,15 +13,15 @@ type pingResultMsg struct {
|
||||||
IP string
|
IP string
|
||||||
}
|
}
|
||||||
|
|
||||||
type item struct {
|
type menuItem struct {
|
||||||
id uint8
|
id uint8
|
||||||
title, desc string
|
title, desc string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i item) ID() uint8 { return i.id }
|
func (i menuItem) ID() uint8 { return i.id }
|
||||||
func (i item) Title() string { return i.title }
|
func (i menuItem) Title() string { return i.title }
|
||||||
func (i item) Description() string { return i.desc }
|
func (i menuItem) Description() string { return i.desc }
|
||||||
func (i item) FilterValue() string { return i.title }
|
func (i menuItem) FilterValue() string { return i.title }
|
||||||
|
|
||||||
const (
|
const (
|
||||||
domainListAll uint8 = iota
|
domainListAll uint8 = iota
|
||||||
|
|
@ -42,13 +42,13 @@ type Model struct {
|
||||||
|
|
||||||
func New(client *porkbun.Client) *Model {
|
func New(client *porkbun.Client) *Model {
|
||||||
items := []list.Item{
|
items := []list.Item{
|
||||||
item{id: domainListAll, title: "Domain: List All", desc: "List all domains in your account"},
|
menuItem{id: domainListAll, title: "Domain: List All", desc: "List all domains in your account"},
|
||||||
item{id: domainGetDetails, title: "Domain: Get Details", desc: "Get details for a specific domain"},
|
menuItem{id: domainGetDetails, title: "Domain: Get Details", desc: "Get details for a specific domain"},
|
||||||
item{id: dnsRetrieveRecords, title: "DNS: Retrieve Records", desc: "Retrieve DNS records for a domain"},
|
menuItem{id: dnsRetrieveRecords, title: "DNS: Retrieve Records", desc: "Retrieve DNS records for a domain"},
|
||||||
item{id: dnsCreateRecord, title: "DNS: Create Record", desc: "Create a new DNS record"},
|
menuItem{id: dnsCreateRecord, title: "DNS: Create Record", desc: "Create a new DNS record"},
|
||||||
item{id: dnsEditRecord, title: "DNS: Edit Record", desc: "Edit an existing DNS record"},
|
menuItem{id: dnsEditRecord, title: "DNS: Edit Record", desc: "Edit an existing DNS record"},
|
||||||
item{id: dnsDeleteRecord, title: "DNS: Delete Record", desc: "Delete a DNS record"},
|
menuItem{id: dnsDeleteRecord, title: "DNS: Delete Record", desc: "Delete a DNS record"},
|
||||||
item{id: utilPing, title: "Util: Ping", desc: "Ping Porkbun"},
|
menuItem{id: utilPing, title: "Util: Ping", desc: "Ping Porkbun"},
|
||||||
}
|
}
|
||||||
|
|
||||||
l := list.New(items, list.NewDefaultDelegate(), 0, 0)
|
l := list.New(items, list.NewDefaultDelegate(), 0, 0)
|
||||||
|
|
@ -81,7 +81,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.String() == "enter" {
|
if msg.String() == "enter" {
|
||||||
i, ok := m.list.SelectedItem().(item)
|
i, ok := m.list.SelectedItem().(menuItem)
|
||||||
if ok {
|
if ok {
|
||||||
return m.handleSelection(i)
|
return m.handleSelection(i)
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +108,7 @@ func (m *Model) View() string {
|
||||||
return m.list.View()
|
return m.list.View()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) handleSelection(i item) (tea.Model, tea.Cmd) {
|
func (m *Model) handleSelection(i menuItem) (tea.Model, tea.Cmd) {
|
||||||
// TODO: Implement other actions. For now, just Ping.
|
// TODO: Implement other actions. For now, just Ping.
|
||||||
switch i.id {
|
switch i.id {
|
||||||
case utilPing:
|
case utilPing:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue