summaryrefslogtreecommitdiff
path: root/model_list.go
diff options
context:
space:
mode:
Diffstat (limited to 'model_list.go')
-rw-r--r--model_list.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/model_list.go b/model_list.go
index 12f2238..8ffdb49 100644
--- a/model_list.go
+++ b/model_list.go
@@ -2,9 +2,11 @@ package main
import (
"encoding/csv"
+ "fmt"
"os"
"os/exec"
"strings"
+ "time"
tea "charm.land/bubbletea/v2"
)
@@ -76,3 +78,32 @@ 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 {
+ 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)
+}