1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Dialog-based interaction scripting.
//!
//! This module provides a high-level abstraction for scripting
//! interactive terminal sessions using dialog definitions.
//!
//! Dialogs define a sequence of expect/send steps that can be executed
//! against a session. They support variable substitution and branching.
//!
//! # Examples
//!
//! ## Basic Dialog
//!
//! ```
//! use rust_expect::{Dialog, DialogStep};
//!
//! // Create a simple login dialog
//! let dialog = Dialog::named("login")
//! .step(DialogStep::new("username")
//! .with_expect("login:")
//! .with_send("admin\n"))
//! .step(DialogStep::new("password")
//! .with_expect("password:")
//! .with_send("secret\n"));
//!
//! assert_eq!(dialog.len(), 2);
//! ```
//!
//! ## With Variables
//!
//! ```
//! use rust_expect::{Dialog, DialogStep};
//!
//! // Variables are substituted in send text
//! let dialog = Dialog::named("login")
//! .variable("USER", "admin")
//! .variable("PASS", "secret123")
//! .step(DialogStep::new("username")
//! .with_expect("login:")
//! .with_send("${USER}\n"))
//! .step(DialogStep::new("password")
//! .with_expect("password:")
//! .with_send("${PASS}\n"));
//!
//! // Variables are substituted when executing
//! assert_eq!(dialog.substitute("${USER}"), "admin");
//! ```
//!
//! ## Using the Builder
//!
//! ```
//! use rust_expect::DialogBuilder;
//!
//! let dialog = DialogBuilder::named("setup")
//! .var("HOST", "server.example.com")
//! .expect_send("prompt", "> ", "connect ${HOST}\n")
//! .expect_send("auth", "password:", "mypassword\n")
//! .build();
//!
//! assert_eq!(dialog.name, "setup");
//! ```
//!
//! ## Async Execution
//!
//! ```ignore
//! use rust_expect::{Session, Dialog, DialogStep};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), rust_expect::ExpectError> {
//! let mut session = Session::spawn("/bin/bash", &[]).await?;
//!
//! let dialog = Dialog::named("example")
//! .step(DialogStep::new("prompt")
//! .with_expect("$ ")
//! .with_send("echo hello\n"));
//!
//! let result = session.run_dialog(&dialog).await?;
//! assert!(result.success);
//! Ok(())
//! }
//! ```
pub use *;
pub use ;
pub use ;