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
- Host: GitHub
- URL: https://github.com/techassi/rupl
- Owner: Techassi
- License: gpl-3.0
- Created: 2023-01-03T23:05:48.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T15:50:18.000Z (almost 3 years ago)
- Last Synced: 2025-01-15T12:15:17.439Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)))
}
```