3 releases (breaking)

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

#390 in Command-line interface

Download history 1463/week @ 2023-10-19 957/week @ 2023-10-26 900/week @ 2023-11-02 1226/week @ 2023-11-09 1158/week @ 2023-11-16 1221/week @ 2023-11-23 1388/week @ 2023-11-30 2013/week @ 2023-12-07 887/week @ 2023-12-14 960/week @ 2023-12-21 946/week @ 2023-12-28 1062/week @ 2024-01-04 1495/week @ 2024-01-11 1001/week @ 2024-01-18 1949/week @ 2024-01-25 890/week @ 2024-02-01

5,480 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