Wish I knew how to write command line tools like this. Until then, there's always Emacs.
Easiest way to do it any language is to shell out to gum: https://github.com/charmbracelet/gum
For more fine grained controls, you can look into TUI frameworks like bubbletea, ratatui, Textual etc.