reedline-repl-rs

Library to help you create a fancy REPL for your application based on nushell's reedline.

License: MIT Crates.io Documentation

Features: - Uses Clap to define commands and arguments - Interactive tab-completion - Fish-style history autosuggestions - Command Syntax highlighting - (optional) File-based command History - Clear input with CTRL+C, exit repl with CTRL+D

Basic example code:

```rust use reedlinereplrs::{Repl, Result}; use clap::{Arg, ArgMatches, Command};

// Write "Hello" with given name fn hello(args: &ArgMatches, context: &mut T) -> Result> { Ok(Some(format!("Hello, {}", args.valueof("who").unwrap()))) }

const PROMPT: &str = "MyApp";

fn main() -> Result<()> { let mut repl = Repl::new(()) .withname("MyApp") .withversion("v0.1.0") .withprompt(&PROMPT) .withdescription("My very cool app") .withbanner("Welcome to MyApp") .addcommand( Command::new("hello") .arg(Arg::new("who").required(true)) .about("Greetings!"), hello ); repl.run() } ```

Running the example above:

```plain Welcome to MyApp MyApp〉help MyApp v0.1.0: My very cool app

COMMANDS: hello Greetings! help Print this message or the help of the given subcommand(s)

MyApp〉help hello hello Greetings!

USAGE: hello

ARGS:

OPTIONS: -h, --help Print help information MyApp〉hello Friend Hello, Friend MyApp〉 ```

Thanks

Forked from repl-rs by Jacklund, changed to use reedline which is an advanced readline clone and the base of nushell.