virtual-tty-pty 0.1.0

PTY integration for virtual-tty - run real processes in virtual terminals
Documentation
  • Coverage
  • 18.18%
    2 out of 11 items documented0 out of 10 items with examples
  • Size
  • Source code size: 11.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • XaveScor/virtual-tty
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • XaveScor

virtual-tty-pty

PTY integration for virtual-tty - run real processes in virtual terminals for integration testing.

Features

  • Real Process Execution: Run actual terminal applications (vim, less, bash) in virtual terminals
  • PTY Integration: Uses pseudo-TTY for realistic terminal emulation
  • Input/Output Control: Send input and capture output from running processes
  • Integration Testing: Test your CLI tools against real terminal applications

Usage

use virtual_tty_pty::PtyAdapter;
use std::process::Command;

// Create a PTY adapter
let mut pty = PtyAdapter::new(80, 24)?;

// Spawn a command
let mut child = pty.spawn_command(
    Command::new("echo").arg("Hello from PTY!")
)?;

// Wait for completion
child.wait()?;

// Get the output
println!("{}", pty.get_snapshot());

Interactive Sessions

use virtual_tty_pty::PtyAdapter;
use std::process::Command;

let mut pty = PtyAdapter::new(80, 24)?;
let mut child = pty.spawn_command(Command::new("bash"))?;

// Send commands
pty.send_input_str("echo 'Hello'\n")?;
pty.send_input_str("ls -la\n")?;
pty.send_input_str("exit\n")?;

child.wait()?;

Platform Support

This crate requires Unix-like systems (Linux, macOS) due to PTY API dependencies.

Use Cases

  • Integration testing with real terminal applications
  • Validating ANSI escape sequence handling
  • Testing interactive CLI tools
  • Automating terminal-based workflows

License

MIT