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
Ok(Some((first + second).to_string()))
}
// Write "Hello"
fn hello
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
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> ```
Forked from repl-rs by Jacklund, changed to use reedline which an advanced readline clone and the base of nushell.