package main import ( "fmt" "math/rand" "os" "strings" "time" "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) func getTitle() string { titles := []string{ "yo bum rush the show", "can i kick it?", "super nintendo sega genesis", "birthdays was the worst days", "where were you when we were getting high?", "it's real time, real time, time to get real", } return titles[rand.Intn(len(titles))] } const ( signupDir = "/town/signups" acceptedDir = "/town/signups/accepted" rejectedDir = "/town/signups/rejected" ) // TODO copypasta from signup cmd type townApplication struct { When time.Time Answers map[string]string } func (a townApplication) Render() string { // TODO return "TODO" } func getApplications() ([]townApplication, error) { entries, err := os.ReadDir(signupDir) if err != nil { return nil, fmt.Errorf("failed to read '%s': %w", signupDir, err) } out := []townApplication{} for _, entry := range entries { if !strings.HasSuffix(entry.Name(), "json") { continue } // TODO read file // TODO unmarshal // TODO append } // TODO return out, nil } func _main() error { rand.Seed(time.Now().Unix()) applications, err := getApplications() if err != nil { return fmt.Errorf("could not get applications: %w", err) } pages := tview.NewPages() mainFlex := tview.NewFlex() title := tview.NewTextView() title.SetText(getTitle()) appView := tview.NewTextView() if len(applications) == 0 { appView.SetText("no applications found.") } else { appView.SetText(applications[0].Render()) } legend := tview.NewTextView() legend.SetText("TODO actions legend") mainFlex.SetDirection(tview.FlexRow) mainFlex.AddItem(title, 1, -1, false) mainFlex.AddItem(appView, 0, 1, true) mainFlex.AddItem(legend, 1, -1, false) pages.AddPage("main", mainFlex, true, true) // TODO page for textarea to notate app := tview.NewApplication() app.SetRoot(pages, true) app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { switch event.Rune() { case 's': // TODO skip case 'r': // TODO skip to random case 'A': // TODO approve case 'R': // TODO reject case 'n': // TODO notate case 'Q': app.Stop() } return event }) return app.Run() } func main() { err := _main() if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } }