rusty_repl 0.2.0

REPL library with customisable prompts and clean terminal management.
Documentation

๐Ÿฆ€ rusty_repl

A lightweight, modular framework for building interactive REPLs in Rust โ€” with clean prompts, terminal isolation, and customisable input handling.


โœจ Features

  • ๐Ÿ–ฅ๏ธ Alternate screen mode โ€” clean, isolated terminal workspace
  • ๐Ÿ’ฌ Custom prompts โ€” easily define your own Prompt style
  • โšก Input handling loop โ€” powered by reedline
  • ๐Ÿงน Automatic cleanup โ€” restores cursor, title, and screen on exit
  • ๐ŸŽจ Keyword highlighting โ€” built-in highlighter with custom color schemes
  • ๐Ÿงฉ Extensible design - drop in new highlighters, prompts, or REPL logic

๐Ÿš€ Quick Start

Add to your Cargo.toml:

[dependencies]
rusty_repl = "0.2.0"

Then in your project:

use rusty_repl::{Color, KeywordStyle, Repl};

fn handle_input(cmd: String) -> bool {
    match cmd.as_str() {
        "e" | "q" | "quit" | "exit" => true,
        val => {
            println!("{val}");
            false
        }
    }
}

fn main() {
    let ks = KeywordStyle::new(vec!["ls", "pwd", "cd"], Color::Green);
    let repl_manager = Repl::new("REPL", Some(ks), None);
    let _ = repl_manager.run(handle_input);
}

This opens an alternate terminal screen with a minimal prompt.

Type exit to leave the session.

๐Ÿงฉ Architecture

Module Responsibility
repl::input Handles user input with reedline
repl::terminal Manages terminal (alternate screen, cursor, cleanup)
repl::prompt Defines a cleaner, customisable prompt
repl::highlighter Highlights configured keywords during input
repl::style Configures keyword styles (colors, word list)
repl::repl Connects all components into a cohesive REPL session

Top-level entrypoint:

use rusty_repl::Repl;

๐Ÿ”ง Future Enhancements

  • ๐Ÿ’พ Persistent command history
  • ๐Ÿง  Syntax-aware input completion
  • ๐ŸŒˆ Theming and multi-color highlighting

๐Ÿ“œ License

Licensed under the MIT License