1 unstable release
Uses new Rust 2024
| 0.1.0 | Jan 5, 2026 |
|---|
#1056 in Testing
1MB
25K
SLoC
rust-expect
A modern, async-first terminal automation library for Rust, inspired by the classic Expect tool.
Features
- Async/Await First: Built on Tokio for efficient, non-blocking I/O
- Pattern Matching: Literal strings, regular expressions, and glob patterns
- PTY Support: Full pseudo-terminal support on Unix and Windows
- SSH Integration: Built-in SSH session management (optional)
- Screen Emulation: Virtual terminal with ANSI escape sequence support
- PII Redaction: Automatic sensitive data masking
- Dialog Scripting: Declarative conversation flows
- Human-like Typing: Configurable typing simulation
Usage
use rust_expect::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut session = Session::spawn("bash")?;
session.expect("$ ").await?;
session.send("echo 'Hello!'\n").await?;
session.expect("Hello!").await?;
session.send("exit\n").await?;
Ok(())
}
Feature Flags
ssh- SSH session supportmock- Mock sessions for testingscreen- Virtual terminal emulationpii-redaction- Automatic PII maskingtest-utils- Testing utilitiesmetrics- Performance metricsfull- All features
License
Licensed under MIT or Apache-2.0.
Dependencies
~15–56MB
~1M SLoC