1use easy_repl::{Repl, CommandStatus, command};
2use anyhow::{self, Context};
3
4fn main() -> anyhow::Result<()> {
5 let mut repl = Repl::builder()
6 .add("describe", command! {
7 "Variant 1",
8 () => || {
9 println!("No arguments");
10 Ok(CommandStatus::Done)
11 }
12 })
13 .add("describe", command! {
14 "Variant 2",
15 (a: i32, b: i32) => |a, b| {
16 println!("Got two integers: {} {}", a, b);
17 Ok(CommandStatus::Done)
18 }
19 })
20 .add("describe", command! {
21 "Variant 3",
22 (a: i32, b: String) => |a, b| {
23 println!("An integer `{}` and a string `{}`", a, b);
24 Ok(CommandStatus::Done)
25 }
26 })
27 .build().context("Failed to create repl")?;
28
29 repl.run().context("Critical REPL error")?;
30
31 Ok(())
32}