#win32 #terminal #shell #con-pty

conpty

A library which provides an interface for ConPTY

5 unstable releases

Uses new Rust 2021

0.3.0 Dec 21, 2021
0.2.1 Sep 12, 2021
0.2.0 Sep 12, 2021
0.1.1 Sep 7, 2021
0.1.0 Sep 6, 2021

#73 in Windows APIs

Download history 20/week @ 2022-03-11 24/week @ 2022-03-18 37/week @ 2022-03-25 11/week @ 2022-04-01 14/week @ 2022-04-08 6/week @ 2022-04-15 10/week @ 2022-04-22 30/week @ 2022-04-29 90/week @ 2022-05-06 93/week @ 2022-05-13 25/week @ 2022-05-20 48/week @ 2022-05-27 105/week @ 2022-06-03 24/week @ 2022-06-10 20/week @ 2022-06-17 38/week @ 2022-06-24

201 downloads per month
Used in 2 crates (via expectrl)

MIT license

31KB
616 lines

conpty Crate docs.rs license

A library which provides an interface for ConPTY.

It is originally developed to be a windows backend for zhiburt/expectrl.

Get started

use std::io::prelude::*;

fn main() {
    let proc = conpty::spawn("echo Hello World").unwrap();
    let mut reader = proc.output().unwrap();

    println!("Process has pid={}", proc.pid());

    proc.wait(None).unwrap();

    let mut buf = [0; 1028];
    let n = reader.read(&mut buf).unwrap();
    assert!(String::from_utf8_lossy(&buf[..n]).contains("Hello World"));
}

lib.rs:

A library which provides an interface for ConPTY.

# // todo: determine why this test timeouts if runnin as a doc test but not as an example.
use std::io::prelude::*;

fn main() {
    let proc = conpty::spawn("echo Hello World").unwrap();
    let mut reader = proc.output().unwrap();

    println!("Process has pid={}", proc.pid());

    proc.wait(None).unwrap();

    let mut buf = [0; 1028];
    let n = reader.read(&mut buf).unwrap();
    assert!(String::from_utf8_lossy(&buf[..n]).contains("Hello World"));
}

Dependencies

~214MB
~3.5M SLoC