Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
examples/ | 03-May-2024 | - | 10 | 7 | ||
src/ | 03-May-2024 | - | 211 | 144 | ||
.cargo_vcs_info.json | D | 03-May-2024 | 74 | 6 | 5 | |
.gitignore | D | 03-May-2024 | 23 | 4 | 3 | |
Android.bp | D | 03-May-2024 | 761 | 34 | 29 | |
CHANGELOG.md | D | 03-May-2024 | 1.6 KiB | 74 | 38 | |
Cargo.toml | D | 03-May-2024 | 1.3 KiB | 35 | 33 | |
Cargo.toml.orig | D | 03-May-2024 | 766 | 27 | 21 | |
LICENSE | D | 03-May-2024 | 1 KiB | 21 | 17 | |
METADATA | D | 03-May-2024 | 363 | 20 | 19 | |
MODULE_LICENSE_MIT | D | 03-May-2024 | 0 | |||
OWNERS | D | 03-May-2024 | 40 | 2 | 1 | |
README.md | D | 03-May-2024 | 1.7 KiB | 75 | 52 | |
rustfmt.toml | D | 03-May-2024 | 215 | 4 | 4 |
README.md
1 # atty 2 3 [](https://travis-ci.org/softprops/atty) [](https://ci.appveyor.com/project/softprops/atty) [](https://coveralls.io/github/softprops/atty?branch=master) [](https://crates.io/crates/atty) [](http://docs.rs/atty) [](https://softprops.github.io/atty) 4 5 > are you or are you not a tty? 6 7 8 ## install 9 10 Add the following to your `Cargo.toml` 11 12 ```toml 13 [dependencies] 14 atty = "0.2" 15 ``` 16 17 ## usage 18 19 ```rust 20 use atty::Stream; 21 22 fn main() { 23 if atty::is(Stream::Stdout) { 24 println!("I'm a terminal"); 25 } else { 26 println!("I'm not"); 27 } 28 } 29 ``` 30 31 ## testing 32 33 This library has been unit tested on both unix and windows platforms (via appveyor). 34 35 36 A simple example program is provided in this repo to test various tty's. By default. 37 38 It prints 39 40 ```bash 41 $ cargo run --example atty 42 stdout? true 43 stderr? true 44 stdin? true 45 ``` 46 47 To test std in, pipe some text to the program 48 49 ```bash 50 $ echo "test" | cargo run --example atty 51 stdout? true 52 stderr? true 53 stdin? false 54 ``` 55 56 To test std out, pipe the program to something 57 58 ```bash 59 $ cargo run --example atty | grep std 60 stdout? false 61 stderr? true 62 stdin? true 63 ``` 64 65 To test std err, pipe the program to something redirecting std err 66 67 ```bash 68 $ cargo run --example atty 2>&1 | grep std 69 stdout? false 70 stderr? false 71 stdin? true 72 ``` 73 74 Doug Tangren (softprops) 2015-2019 75