diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-07-15 02:17:57 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-07-15 02:17:57 -0400 |
commit | 3d54d1f4cb7274280f4e01e101137e91f336bc5c (patch) | |
tree | 896ecd9b9bd8696c9818c0779cd1d35876adec84 /examples | |
parent | 489a8198828be02c92da0c771ae0864915b08e7f (diff) | |
download | pty-process-3d54d1f4cb7274280f4e01e101137e91f336bc5c.tar.gz pty-process-3d54d1f4cb7274280f4e01e101137e91f336bc5c.zip |
start of an implementation
Diffstat (limited to 'examples')
-rw-r--r-- | examples/basic.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/basic.rs b/examples/basic.rs new file mode 100644 index 0000000..8240d12 --- /dev/null +++ b/examples/basic.rs @@ -0,0 +1,14 @@ +use std::io::{Read as _, Write as _}; + +fn main() { + let mut cmd = pty_process::Command::new("ls").unwrap(); + cmd.args(&["--color=auto"]); + let mut child = cmd.spawn().unwrap(); + let mut buf = [0_u8; 1]; + loop { + cmd.pty().read_exact(&mut buf).unwrap(); + print!("{}", buf[0] as char); + std::io::stdout().flush().unwrap(); + } + child.wait().unwrap(); +} |