use rexpect::error::Error;
use rexpect::session::PtyReplSession;
use rexpect::spawn;
fn ed_session() -> Result<PtyReplSession, Error> {
let mut ed = PtyReplSession::new(spawn("/bin/ed -p '> '", Some(2000))?, "> ".to_owned())
.echo_on(false)
.quit_command(Some("Q".to_owned()));
ed.wait_for_prompt()?;
Ok(ed)
}
fn main() -> Result<(), Error> {
let mut ed = ed_session()?;
ed.send_line("a")?;
ed.send_line("ed is the best editor evar")?;
ed.send_line(".")?;
ed.wait_for_prompt()?;
ed.send_line(",l")?;
ed.exp_string("ed is the best editor evar$")?;
ed.send_line("Q")?;
ed.exp_eof()?;
Ok(())
}