peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.05k stars 132 forks source link

able to save history for invalid prompts #89

Closed sukrithanda closed 7 years ago

sukrithanda commented 7 years ago

Would it be possible to add a configuration to allow invalid and valid prompts to be saved in history? for longer prompts if a typo occurs the user has to retype the entire prompt.

peterh commented 7 years ago

Liner does not have any way to know which prompts are valid. Feel free to call AppendHistory with any string that you think will be useful to your users.

sukrithanda commented 7 years ago

"AppendHistory should be called iff Prompt returns a valid command." Any reason for this comment in the docs?

peterh commented 7 years ago

For the programs I have written, invalid commands are noise, and not useful to me. Plus, if I want most of a previous invalid command I can copy-and-paste in the terminal. But then, my command lines tend to be very short, so they're easy to manage. The decision may be different if your program has longer command lines.

sukrithanda commented 7 years ago

thanks! makes sense