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
89
90
91
92
93
94
95
96
97
98
99
100
//! Session module for managing spawned process interactions.
//!
//! This module provides the core session types and functionality for
//! interacting with spawned processes, including the session handle,
//! builder, lifecycle management, and screen buffer integration.
//!
//! # Overview
//!
//! The [`Session`] type is the main entry point for interacting with
//! terminal applications. It provides methods for:
//!
//! - Spawning processes with [`Session::spawn`]
//! - Sending input with [`Session::send`], [`Session::send_line`]
//! - Expecting output with [`Session::expect`], [`Session::expect_any`]
//! - Running dialogs with [`Session::run_dialog`]
//!
//! # Examples
//!
//! ## Basic Usage
//!
//! ```ignore
//! use rust_expect::Session;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), rust_expect::ExpectError> {
//! // Spawn a bash shell
//! let mut session = Session::spawn("/bin/bash", &[]).await?;
//!
//! // Wait for the prompt
//! session.expect("$ ").await?;
//!
//! // Send a command
//! session.send_line("echo 'Hello, World!'").await?;
//!
//! // Expect the output
//! session.expect("Hello, World!").await?;
//!
//! // Clean exit
//! session.send_line("exit").await?;
//! Ok(())
//! }
//! ```
//!
//! ## Using the Builder
//!
//! ```ignore
//! use rust_expect::SessionBuilder;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), rust_expect::ExpectError> {
//! let mut session = SessionBuilder::new()
//! .command("/bin/bash")
//! .args(&["-l"])
//! .timeout(Duration::from_secs(30))
//! .dimensions(120, 40)
//! .env("TERM", "xterm-256color")
//! .spawn()
//! .await?;
//!
//! session.expect("$ ").await?;
//! Ok(())
//! }
//! ```
//!
//! ## Multi-Pattern Matching
//!
//! ```ignore
//! use rust_expect::{Session, Pattern, PatternSet};
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), rust_expect::ExpectError> {
//! let mut session = Session::spawn("/bin/bash", &[]).await?;
//!
//! // Create a pattern set with multiple options
//! let mut patterns = PatternSet::new();
//! patterns
//! .add(Pattern::literal("$ "))
//! .add(Pattern::literal("# "))
//! .add(Pattern::timeout(Duration::from_secs(5)));
//!
//! // Expect any of the patterns
//! let result = session.expect_any(&patterns).await?;
//! println!("Matched: {}", result.matched);
//! Ok(())
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;