The easy Rust Read-Evaluate-Print-Loop (REPL) utility crate
rustyrepl
is a simple crate to facilitate creation of Read, Evaluate, Print, Loop utilities at the command-line. A unique combination of rustyline
and clap
to build a simple REPL interface
with handy argument parsing.
First, add rustyrepl to your Cargo.toml
file
toml
[dependencies]
rustyrepl = "0.2"
Next:
```rust use anyhow::Result; use clap::{Parser, Subcommand}; use rustyrepl::{Repl, ReplCommandProcessor}; /// The enum of sub-commands supported by the CLI
pub enum Command { /// Execute a test command Test, } /// The general CLI, essentially a wrapper for the sub-commands [Commands]
pub struct Cli { #[clap(subcommand)] command: Command, }
pub struct CliProcessor {}
impl ReplCommandProcessor
async fn main() -> Result<()> {
let processor: Box
This small program will startup up a REPL with the prompt ">>" which you can interact with
```text
help The general CLI, essentially a wrapper for the sub-commands [Commands]
Usage: repl-interface
Commands: test Execute a test command help Print this message or the help of the given subcommand(s)
Options: -h, --help Print help
```