dialog!() { /* proc-macro */ }Expand description
Define an interactive dialog script.
Creates a Dialog that can be executed against a session, automating
send/expect sequences.
§Commands
send "text"- Send text without newlinesendln "text"- Send text with newlineexpect "pattern"- Wait for literal patternexpect_re "regex"- Wait for regex pattern (validated at compile time)wait duration- Wait for a durationtimeout duration- Set timeout for subsequent operations
§Examples
ⓘ
use rust_expect_macros::dialog;
use std::time::Duration;
let login_script = dialog! {
timeout Duration::from_secs(30);
expect "login:";
sendln "admin";
expect "password:";
sendln "secret123";
expect_re r"\$\s*$"
};
// Execute the dialog
session.run_dialog(&login_script).await?;