reedline-repl-rs

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

Features: - Uses Clap to define commands and arguments - Interactive tab-completion - Fish-style history autosuggestions - Syntax highlighting - (optional) file based command History

Basic example code:

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

// Add two numbers. fn add(args: &ArgMatches, context: &mut T) -> Result> { let first: i32 = matches.valueof("first").unwrap().parse().unwrap(); let second: i32 = matches.value_of("second").unwrap().parse().unwrap();

Ok(Some((first + second).to_string()))

}

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

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

Running the example above:

```bash % my_app Welcome to MyApp MyApp> help

MyApp v0.1.0: My very cool app

add - Add two numbers together hello - Greetings! MyApp> help add add: Add two numbers together Usage: add first second MyApp> add 1 2 3 MyApp> ```

Thanks

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