nskins / goby

Command-line role-playing game framework
MIT License
122 stars 56 forks source link

Command history feature #88

Closed lsribeiro closed 7 years ago

lsribeiro commented 7 years ago

Requested in #66. Since it is on hold, I'm not sure if I should have implemented it, but I did it anyway. I just had to replace the input method from gets.chomp to Readline. (https://ruby-doc.org/stdlib-2.1.0/libdoc/readline/rdoc/Readline.html). The reason I chose Readline, it's because it already provides a history feature, including scrolling up and down with the arrow keys. Unfortunatelly, it doesn't work well with RSpec, so, I had to reuse gets in the test enviroment. I coded so the history would ignore single character commands, since it is faster to type them out, rather than search for them in the history. It also ignores repeated commands typed consecutively.

nskins commented 7 years ago

Hi @lsribeiro - Thank you for implementing this! It's on hold because I had an idea about an alternative feature using the arrow keys. I will do a code review and let you know what I think when I have some time. For now, I noticed that you will need to print a newline after the input is received (as it used to do).

nskins commented 7 years ago

Thanks @lsribeiro! Merged!