dialog

Macro dialog 

Source
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 newline
  • sendln "text" - Send text with newline
  • expect "pattern" - Wait for literal pattern
  • expect_re "regex" - Wait for regex pattern (validated at compile time)
  • wait duration - Wait for a duration
  • timeout 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?;