virtual-tty-pty

Crates.iovirtual-tty-pty
lib.rsvirtual-tty-pty
version0.1.0
created_at2025-07-09 21:40:38.1087+00
updated_at2025-07-09 21:40:38.1087+00
descriptionPTY integration for virtual-tty - run real processes in virtual terminals
homepage
repositoryhttps://github.com/xavescor/virtual-tty
max_upload_size
id1745542
size12,281
(XaveScor)

documentation

README

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

Commit count: 0

cargo fmt