//! Example using Repl with a custom error type. use reedline_repl_rs::clap::{Arg, ArgMatches, Command}; use reedline_repl_rs::{Repl, Result}; /// Write "Hello" with given name async fn hello(args: ArgMatches, _context: &mut T) -> Result> { Ok(Some(format!( "Hello, {}", args.get_one::("who").unwrap() ))) } /// Called after successful command execution, updates prompt with returned Option async fn update_prompt(_context: &mut T) -> Result> { Ok(Some("updated".to_string())) } #[tokio::main] async fn main() -> Result<()> { let mut repl = Repl::new(()) .with_name("MyApp") .with_version("v0.1.0") .with_command_async( Command::new("hello") .arg(Arg::new("who").required(true)) .about("Greetings!"), |args, context| Box::pin(hello(args, context)), ) .with_on_after_command_async(|context| Box::pin(update_prompt(context))); repl.run_async().await }