ianxm / ihx

The interactive haXe shell
http://github.com/ianxm/ihx
Other
79 stars 10 forks source link

Preserve History between ConsoleReader sessions #17

Closed NQNStudios closed 4 years ago

NQNStudios commented 4 years ago

I've been working on a language in Haxe with a Repl and realized today that I can use your ConsoleReader class to get command history functionality. Which is awesome.

Since I'm debugging expressions in my language, then fiddling around with the interpreter, relaunching, and testing the same expression again, it would be nice if command history could be serialized to a dotfile. Right now History is a private variable in ConsoleReader that's constructed every time -- would you accept a PR that adds optional serialization/deserialization of a History object?

ianxm commented 4 years ago

Yes, that sounds fine.

How were you thinking of making it optional? Were you thinking of adding a command line option to enable it?

Be careful not to tie the implementation to a particular platform.

On Mon, May 18, 2020, 10:33 PM Nat Quayle Nelson notifications@github.com wrote:

I've been working on a language in Haxe with a Repl and realized today that I can use your ConsoleReader class to get command history functionality. Which is awesome.

Since I'm debugging expressions in my language, then fiddling around with the interpreter, relaunching, and testing the same expression again, it would be nice if command history could be serialized to a dotfile. Right now History is a private variable in ConsoleReader that's constructed every time -- would you accept a PR that adds optional serialization/deserialization of a History object?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ianxm/ihx/issues/17, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL7I4YMYTL6PBUMYH55TDRSHVTRANCNFSM4NES7ANQ .

NQNStudios commented 4 years ago

For the implementation, I'm thinking:

ianxm commented 4 years ago

that sounds good.

On Thu, May 21, 2020 at 4:45 PM Nat Quayle Nelson notifications@github.com wrote:

For the implementation, I'm thinking:

  • Add optional parameters to ConsoleReader.new(): one is a file path for the persistent history file, the other is a maximum number of commands to store in that file
  • At construction, if the the file path is provided, load the history list from that file
  • When a command is saved to the history, also update the file
  • Add command line options that can be passed to the ConsoleReader.new()

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ianxm/ihx/issues/17#issuecomment-632335311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL7I3PKV52QRPIF3QXCZ3RSWHBVANCNFSM4NES7ANQ .

ianxm commented 4 years ago

pull request merged. thanks!