caprice is a work in progress REPL for Rust projects featuring an easy to use, zsh like
autocomplete feature.
using caprice with the spinning square example from Piston
Usage
- typing #list will print all available tokens in the caprice console in alphabetical order
- pressing tab will cycle between all autocompleted suggestions
caprice uses crossterm as its terminal emulator.
Example:
use caprice::{Caprice, CapriceCommand};
use std::thread;
use std::time::Duration;
fn main() {
let mut caprice = Caprice::new()
.set_prompt("!:") .disable_ctrl_c() .init(); caprice.set_keywords(&[
"some_token".to_owned(),
"some_other_token".to_owned(),
"exit".to_owned(), ]);
let (tx, rx, caprice_handle) = caprice.run().unwrap();
loop {
if let Ok(token) = rx.try_recv() {
match token.as_str() {
"exit" => {
tx.send(CapriceCommand::Println("bye".to_owned())).unwrap();
tx.send(CapriceCommand::Exit).unwrap();
caprice_handle.join().expect("couldn't join thread").expect("Caprice run has encountered an error");
break; },
_ => {
let print_token = format!("Got {} from Caprice", token);
tx.send(CapriceCommand::Println(print_token)).unwrap();
}
}
}
thread::sleep(Duration::from_millis(10));
}
}
Windows terminals
Currently caprice is buggy on all windows terminals