kkawakam / rustyline

Readline Implementation in Rust
https://crates.io/crates/rustyline/
MIT License
1.53k stars 176 forks source link

How to handle partial of the input? #783

Closed tisonkun closed 1 month ago

tisonkun commented 1 month ago

For example, I write a SQL CLI and meet the input SELECT 1; SELECT.

I'd like to treat this line a valid one, but only handle SELECT 1; part, leave the second SELECT part of the next input.

I can identify the tokens and rebuild the remaining part, but it seems rustyline will consume per line, and I don't find a way to consume part of a line.

tisonkun commented 1 month ago

I can somehow consume all the line, if there is an API I can push back the remaining part.

tisonkun commented 1 month ago

Done by let the validator always return Valid and handle the line at one level up.