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
- 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
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〉 ```
Forked from repl-rs by Jacklund, changed to use reedline which is an advanced readline clone and the base of nushell.