From ebadba99afff06bed79054d9f58c81fa477acafa Mon Sep 17 00:00:00 2001 From: nate smith Date: Sun, 1 Sep 2024 15:17:27 -0500 Subject: [PATCH] towncon wip --- cmd/towncon/main.go | 130 +++++++++++++++++++++++++++++++++++------ cmd/towncon/md/info.md | 10 ++++ 2 files changed, 123 insertions(+), 17 deletions(-) diff --git a/cmd/towncon/main.go b/cmd/towncon/main.go index 89a0661..f49964f 100644 --- a/cmd/towncon/main.go +++ b/cmd/towncon/main.go @@ -6,9 +6,11 @@ import ( "math/rand" "os" "os/exec" + "os/user" "path" "strings" + "git.tilde.town/tildetown/town/email" "github.com/charmbracelet/glamour" "github.com/charmbracelet/huh" ) @@ -35,8 +37,103 @@ func banner() (string, error) { } -func pager() *exec.Cmd { - return exec.Command("/usr/bin/bat") +func info() error { + infoContent, err := md.ReadFile("md/info.md") + if err != nil { + return err + } + out, err := glamour.Render(string(infoContent), "dracula") + if err != nil { + return err + } + cmd := exec.Command("/usr/bin/bat") + cmd.Stdin = strings.NewReader(out) + cmd.Stdout = os.Stdout + return cmd.Run() +} + +type physicalData struct { +} + +type rsvpData struct { + Being string + PhysicalData physicalData + Freeform string +} + +func sendRSVPEmail(rd rsvpData) error { + body := "TODO" + + return email.SendLocalEmail("vilmibm", "RSVP TOWNCON24", body) +} + +func rsvp(o opts) error { + var being string + var arriving string + var departing string + var transportation bool + lodging := true + var allergies string + couch := true + var freeform string + + form := huh.NewForm( + huh.NewGroup( + huh.NewSelect[string]().Title("How will you be attending?"). + Options( + huh.NewOption("Digitally", "digital"), + huh.NewOption("Phyiscally", "physical"), + ).Value(&being)), + + // Physical attendee form + huh.NewGroup( + huh.NewInput().Title("When (day/time) are you arriving?"). + Value(&arriving), + huh.NewInput().Title("When (day/time) are you departing?"). + Value(&departing), + ).WithHideFunc(func() bool { + return being != "physical" + }), + huh.NewGroup( + huh.NewConfirm().Title("Will you be staying overnight at the venue?"). + Value(&lodging), + ).WithHideFunc(func() bool { + return being != "physical" + }), + huh.NewGroup( + huh.NewConfirm().Title("If the need arises are you ok sleeping on a couch?"). + Value(&couch), + ).WithHideFunc(func() bool { + return being != "physical" && !lodging + }), + huh.NewGroup( + huh.NewInput().Title("Do you have any food allergies I should be aware of?"). + Value(&allergies), + huh.NewConfirm().Title("Will you need any help getting to the venue?"). + Description("I have a car and have some ability to help getting people to the venue"). + Value(&transportation), + ).WithHideFunc(func() bool { + return being != "physical" + }), + + // Catch all freeform + huh.NewGroup( + huh.NewText(). + Title("Anything you want me to know? Any questions?"). + Value(&freeform))) + + err := form.Run() + if err != nil { + return err + } + + // TODO email + + return nil +} + +type opts struct { + Username string } func _main() error { @@ -47,6 +144,18 @@ func _main() error { fmt.Println(b) + u, err := user.Current() + if err != nil { + return err + } + + o := opts{ + Username: u.Username, + } + + fmt.Printf("\t\t^_^_^_^_^_^_^ hi ~%s ^_^_^_^_^_^_^\n", o.Username) + fmt.Println() + var mode string huh.NewSelect[string]().Title("whuddyu wanna doo?"). @@ -60,22 +169,9 @@ func _main() error { switch mode { case "info": - infoContent, err := md.ReadFile("md/info.md") - if err != nil { - return err - } - out, err := glamour.Render(string(infoContent), "dracula") - if err != nil { - return err - } - cmd := pager() - cmd.Stdin = strings.NewReader(out) - cmd.Stdout = os.Stdout - err = cmd.Run() - if err != nil { - return err - } + return info() case "rsvp": + return rsvp(o) case "submit": case "jam": case "quit": diff --git a/cmd/towncon/md/info.md b/cmd/towncon/md/info.md index 62b8512..7fb7bbe 100644 --- a/cmd/towncon/md/info.md +++ b/cmd/towncon/md/info.md @@ -73,6 +73,12 @@ I'll arrange food throughout the event. There are also plenty of restaurants around the venue if people want to get their own food. +### TRANSPORTATION + +The venue is accessible from rail, bus, and cab/uber/lyft. I have a car and can make myself available to pick people up and get them to the venue once they have made it to Chicago if they need. Depending on timing I might not be able to help, however. Contact via my cell phone (`~vilmibm/phone.txt`) to ask about my availability for a ride during the event. + +If you are driving parking might be tough in the area--I can offer a few spots by my place in Forest Park if you want to put a car there and then get a ride over to the venue. + ### ACTIVITIES I'd like to do a field trip on the 12th...Some potential ideas: @@ -84,3 +90,7 @@ I'd like to do a field trip on the 12th...Some potential ideas: - just hang out and play synths (field trip of the mind) !!! TBD !!! + +## COMMS + +For any kind of emergency during the event please contact me via my cell phone. My number can be found at `~vilmibm/phone.txt`.