Add support for repl
eatonphil opened this issue · comments
Grab https://github.com/chzyer/readline and wrap main.go's query parts (likely line 469-503) in a loop. Allow the loop to keep going if the user passes an -i flag or --interactive flag.
When this flag is in, caching must also be turned on so that the sqlite database is not ephemeral per run (I think).
How would you like the behaviour to be?. like how to exit and stuff.
Control-D to exit for now.
And have dsq >
be the prompt for each line
When you're in interactive mode the pretty flag should probably also be turned on automatically
How should the test be written?
Hmm I'm OK with there not being tests for just the interactive part for now.
Oh yeah I realize now you can't just wrap lines 469-503 in a loop. But you can pull them out into a runQuery helper and then call that helper within a repl loop if interactive mode is on
Okay on it
Are you comfortable with adding a dependency for reading the input.
I was able to implement basic REPL by using the built in bufio package but this doesnt support moving the cursor around with the arrow keys.
Yup, I mentioned a suggested dependency in the original message for this issue