| Crates.io | repline |
| lib.rs | repline |
| version | 0.0.12 |
| created_at | 2025-12-02 06:56:33.530651+00 |
| updated_at | 2026-01-10 03:56:39.725943+00 |
| description | A Readline-like multiline editor for easy REPLication |
| homepage | |
| repository | https://github.com/boxdyn/repline |
| max_upload_size | |
| id | 1961211 |
| size | 41,044 |
Repline is an easy-to-use, fairly sensible multiline terminal editor meant specifically for REPL-ifying existing Rust projects. It aims to provide a simple API and fairly intuitive⢠keybinds, which will probably work in some terminals.
Repline is a component of the Conlang project.
The easiest, most intuitive way to integrate Repline into your project is with
the prebaked interface. This interface provides user input to a passed-in
FnMut lambda as a string each time the user presses the enter key at the end
of the last line.
use repline::prebaked::{read_and, Response};
fn main() -> Result<(), Box<dyn Error>> {
// read_and takes three arguments: an ANSI terminal `color` string,
// a `begin` prompt, which is shown on the first line,
// and an `again` prompt, which is shown on subsequent lines.
//
// It returns a Result<(), repline::error::Error> on I/O failure.
// `read_and` captures the Ctrl+C and Ctrl+D sequences.
//
// See its documentation for more info.
read_and("", ".>", " >", |line| match line.trim() {
// Returning Response::Continue will add a new line with the "again" prompt
"" => Ok(Response::Continue),
// Returning Response::Accept will add the input to history
// and clear the input
"accept" => Ok(Response::Accept),
// Returning Response::Deny will just clear the input
"deny" => Ok(Response::Deny),
// Returning Response::Break will end the loop
"exit" => Ok(Response::Break),
// Returning an Err value will add a new line, (like Response::Continue,)
// but show the formatted error value after the cursor.
command => Err(format!("Unrecognized command: {command}"))?,
})?;
Ok(())
}
More complicated projects may have more complicated needs. To service these, the repline interface is exposed for direct consumption. This can be used if: