I'm creating a CLI tool in golang, let's call it repl
. It reads instructions from stdin delimited by a ;
, applies a function to the statement read, and prints the result to stdout (and goes back to reading)
repl> foo;
"foo"
repl> bar;
"bar"
If I misspell bar
as baer
and want to fix it, I have to delete all characters until a
and then rewrite instead of being able to navigate to the character (using arrow keys) and only deleting that character. Essentially, I'm trying to replicate the behaviour already found in some commercial REPLs such as mysql, python, etc. where you can move between characters using arrow keys. Any suggestions about how to go about doing this?
You could use Readline, it has what you ask for and much more.