diff options
| -rw-r--r-- | model.go | 35 | ||||
| -rw-r--r-- | view.go | 41 |
2 files changed, 41 insertions, 35 deletions
@@ -2,11 +2,9 @@ package main import ( "encoding/csv" - "fmt" "os" "os/exec" "strings" - "time" tea "charm.land/bubbletea/v2" ) @@ -76,36 +74,3 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, nil } - -func (m model) View() tea.View { - s := "Unpublished drafts of this Hugo site:\n\n" - - for i, choice := range m.choices { - if i == 0 { - continue - } - - cursor := " " // no cursor - if m.cursor == i { - cursor = ">" - } - - checked := " " // not checked - if _, ok := m.selected[i]; ok { - checked = "x" - } - - title := choice[2] - t, err := time.Parse(time.RFC3339, choice[3]) - if err != nil { - - } - datetime := t.Format("2006-01-02 15:04") - - s += fmt.Sprintf("%s [%s] %s \t %s\n", cursor, checked, datetime, title) - } - - s += "\n[q] quit | [Enter] edit | [SPACE] select | [↑/k] up | [↓/j] down\n" - - return tea.NewView(s) -} @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + "time" + + tea "charm.land/bubbletea/v2" +) + +func (m model) View() tea.View { + s := "Unpublished drafts of this Hugo site:\n\n" + + for i, choice := range m.choices { + if i == 0 { + continue + } + + cursor := " " // no cursor + if m.cursor == i { + cursor = ">" + } + + checked := " " // not checked + if _, ok := m.selected[i]; ok { + checked = "x" + } + + title := choice[2] + t, err := time.Parse(time.RFC3339, choice[3]) + if err != nil { + + } + datetime := t.Format("2006-01-02 15:04") + + s += fmt.Sprintf("%s [%s] %s \t %s\n", cursor, checked, datetime, title) + } + + s += "\n[q] quit | [Enter] edit | [SPACE] select | [↑/k] up | [↓/j] down\n" + + return tea.NewView(s) +} |
