3 releases (breaking)

0.3.1 Sep 8, 2022
0.2.0 Nov 18, 2020
0.1.0 Nov 13, 2020

#802 in Command-line interface

Download history 44/week @ 2024-07-20 125/week @ 2024-07-27 76/week @ 2024-08-03 78/week @ 2024-08-10 50/week @ 2024-08-17 52/week @ 2024-08-24 76/week @ 2024-08-31 114/week @ 2024-09-07 137/week @ 2024-09-14 252/week @ 2024-09-21 68/week @ 2024-09-28 71/week @ 2024-10-05 52/week @ 2024-10-12 35/week @ 2024-10-19 92/week @ 2024-10-26 43/week @ 2024-11-02

262 downloads per month
Used in 3 crates

MIT license

8KB
99 lines

fake-tty

Documentation

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.

Example

let output = fake_tty::bash_command("ls --color=auto").output().unwrap();
assert!(output.status.success());

let _stdout: String = String::from_utf8(output.stdout).unwrap();

Platform support

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.

No runtime deps