Crates.io | fake-tty |
lib.rs | fake-tty |
version | 0.3.1 |
source | src |
created_at | 2020-11-13 18:09:58.609922 |
updated_at | 2022-09-08 18:20:45.992773 |
description | Run command with bash pretending to be a tty |
homepage | https://github.com/Aloso/to-html/tree/master/crates/fake-tty |
repository | https://github.com/Aloso/to-html |
max_upload_size | |
id | 312048 |
size | 8,286 |
Rust library to run a command in bash, pretending to be a tty. This means that the command will assume that terminal colors and other terminal features are available. This is done by executing the script command.
Note that some programs might still behave differently than they would in a real terminal. For example, on my system, ls
always displays colors in the terminal, but requires --color=auto
when executed in fake-tty.
let output = fake_tty::bash_command("ls --color=auto").output().unwrap();
assert!(output.status.success());
let _stdout: String = String::from_utf8(output.stdout).unwrap();
As of now, fake-tty supports Linux, macOS and FreeBSD.
Adding support other platforms should be easy, if they support bash and the script
command. On Windows, it might be possible to use cmd or PowerShell instead; please send a pull request if you need Windows support.