Charming Cobras with Bubbletea – Part 1
elewis.dev
elewis.dev
So far I've seen CLI entry with Cobra, TUI with Boa, and Config file reader with Viper. Who knows, maybe someone will implement HTML or REST API generators next?
I'm writing my own Cobra alternative [1] so I can generate input methods "from the ground up" so I really enjoy seeing how others approach this problem, especially because my baby arrived early so my time is now much more limited :D
I dabbled in generating the HTML forms for calling the scripts, but what I was really excited to do was design a chatbot that would use the type declarations to ask for the scripts' requirements conversationally ("next I need a number for...") (alas, the chatscript dialog files I wrote are not open source, I would love to revisit if anyone wants to take another stab at NLP->SQL)
But after a couple of days of head scratching and some help from the Bubbletea slack I managed to put something together that works.
The only inconvenience was that I have to redirect logs away from standard out, but once I did that everything else was a work in the park.
Since the application wasn't really made to continuously report progress I had to poll my data structures and re-render the UI every 100ms. But as the data structures are relatively small that wasn't expensive.