tty-reader icon indicating copy to clipboard operation
tty-reader copied to clipboard

Populate history from external source.

Open piotrmurach opened this issue 5 years ago • 2 comments

@roscom suggested in tty-prompt issue "Secondly, I currently manage the history in a redis cache, outside of rb-readline which is then available to all users. On session start up, the REPL currently populates rb-readline history from the redis cache. That would be a handy feature to be able to do that in your tty-* modules."

piotrmurach avatar May 16 '19 23:05 piotrmurach

I too have a REPL and wish to write a history file and load it back when the user restarts the REPL. The ability to pre-populate the history with a file or proc would be a nice addition.

logicminds avatar Jul 02 '20 02:07 logicminds

Hi Corey,

Thanks for using tty-reader and expressing enthusiasm for this feature. I'm currently working on releasing tty-prompt and pastel gems and have more things on my open-source plate to get done. So I'd love it if you could work on this feature and submit PR.

There is already a history file that saves lines in memory. The way I imagine this working is by having an argument in TTY::Reader::History, let's call it source, that would expose some generic APIs for reading and writing. And then have a specific source like TTY::Reader::Source::File that would know how to deal with files loading and retrieval. This way we would pave the way for future extensions like HTTP, DB and other sources. Any thoughts?

piotrmurach avatar Jul 02 '20 20:07 piotrmurach