Hacker Keyboard will allow you to achieve a lot. All, with all CLI programs? That I do not know. There is a learning curve either way. You can also SSH out of your machine with a terminal app (recommend to look into Mosh) if you got a good internet connection such as 4G/LTE or WiFi. Then you can run e.g. Mutt remotely. Use with tmux and never close it.
As for hook up, there's BT and USB OTG.
Re:What Thunderbird Learned at FOSDEM
by arca_vorago on Saturday February 10, 2018 @04:58AM
(#16346651)
Blackberry ftw ;)
I can't even imagine trying to run emacs on an on-screen touch keyboard.