diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index ff882e5..b6633ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ use chrono::{NaiveDateTime, Weekday}; use colored::Colorize; use log::debug; use num_traits::cast::FromPrimitive; +use rustyline::{error::ReadlineError, Editor}; use structopt::StructOpt; use walkdir::{DirEntry, WalkDir}; @@ -231,13 +232,10 @@ fn run() -> Result<()> { } fn repl(opt: &Opt) -> Result<()> { - let stdin = std::io::stdin(); + let mut rl = Editor::<()>::new(); loop { - print!("Query> "); - std::io::stdout().flush()?; - let mut line = String::new(); - stdin.read_line(&mut line)?; - let line = line.trim(); + let line = rl.readline("Query> ")?; + rl.add_history_entry(&line); let parsed = build_filter(&line); match parsed { Ok(filter) => grep(&opt, &*filter)?, |