repl-block

Synopsis
This crate provides a simple and easy way to build a Read-Eval-Print-Loop,
a.k.a. REPL.
Usage
Add a dependency on this crate to your project's Cargo.toml:
[dependencies]
repl-block= "0.9.0"
Then one can use the ReplBuilder type to build an start a REPL like this:
use repl_block::prelude::{ReplBuilder, ReplBlockResult, Utf8PathBuf};
fn main() -> ReplBlockResult<()> {
let mut evaluator = ;
let path = Utf8PathBuf::try_from(env::current_dir()?)?.join(".repl.history");
ReplBuilder::default()
.history_filepath(path)
.evaluator(|query: &str| {
match evaluator.evaluate(query) {
Ok(value) => println!("{value}"),
Err(err) => println!("{err}"),
}
Ok(())
})
.build()? .start()?;
Ok(())
}