An open API service indexing awesome lists of open source software.

https://github.com/techassi/rupl

A highly customizable REPL framework for Rust
https://github.com/techassi/rupl

Last synced: 11 months ago
JSON representation

A highly customizable REPL framework for Rust

Awesome Lists containing this project

README

          

# rupl

A highly customizable REPL framework for Rust.

## Usage

```rust
use rupl::{Arg, Command, FnContext, Repl, ReplResult};

fn main() -> ReplResult<()> {
let mut repl = Repl::new(());

repl.with_prompt(">>")
.with_version("1.0.1-rc2")
.with_welcome_message("This basic REPL says 'Hello, world!'")
.with_exit_message("Exiting... Bye!")
.with_builtins(true)
.ignore_empty_line(true)
.with_output_prompt(Some(":> "))
.with_command(
Command::new("hello", hello)
.with_arg(Arg::new("name"))
.with_arg(Arg::new("end")),
);

repl.run()
}

fn hello(ctx: FnContext<()>) -> ReplResult> {
let name: String = ctx.args().get("name")?;
let end: String = ctx.args().get("end")?;

Ok(Some(format!("Hello, {}{}", name, end)))
}
```