Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
examples/ | H | 03-May-2022 | - | 10 | 7 | |
src/ | H | 03-May-2022 | - | 211 | 144 | |
.cargo-checksum.json | H A D | 03-May-2022 | 89 | 1 | 1 | |
.cargo_vcs_info.json | H A D | 05-Jan-2020 | 74 | 6 | 5 | |
.gitignore | H A D | 12-Sep-2016 | 23 | 4 | 3 | |
CHANGELOG.md | H A D | 05-Jan-2020 | 1.6 KiB | 74 | 38 | |
Cargo.lock | H A D | 05-Jan-2020 | 2 KiB | 50 | 43 | |
Cargo.toml | H A D | 05-Jan-2020 | 1.3 KiB | 35 | 33 | |
Cargo.toml.orig-cargo | H A D | 05-Jan-2020 | 766 | 27 | 21 | |
LICENSE | H A D | 11-Jul-2019 | 1 KiB | 21 | 17 | |
README.md | H A D | 11-Jul-2019 | 1.7 KiB | 75 | 52 | |
rustfmt.toml | H A D | 11-Jul-2019 | 215 | 4 | 4 |
README.md
1# atty 2 3[![Build Status](https://travis-ci.org/softprops/atty.svg?branch=master)](https://travis-ci.org/softprops/atty) [![Build status](https://ci.appveyor.com/api/projects/status/geggrsnsjsuse8cv?svg=true)](https://ci.appveyor.com/project/softprops/atty) [![Coverage Status](https://coveralls.io/repos/softprops/atty/badge.svg?branch=master&service=github)](https://coveralls.io/github/softprops/atty?branch=master) [![crates.io](https://img.shields.io/crates/v/atty.svg)](https://crates.io/crates/atty) [![Released API docs](https://docs.rs/atty/badge.svg)](http://docs.rs/atty) [![Master API docs](https://img.shields.io/badge/docs-master-green.svg)](https://softprops.github.io/atty) 4 5> are you or are you not a tty? 6 7 8## install 9 10Add the following to your `Cargo.toml` 11 12```toml 13[dependencies] 14atty = "0.2" 15``` 16 17## usage 18 19```rust 20use atty::Stream; 21 22fn 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 33This library has been unit tested on both unix and windows platforms (via appveyor). 34 35 36A simple example program is provided in this repo to test various tty's. By default. 37 38It prints 39 40```bash 41$ cargo run --example atty 42stdout? true 43stderr? true 44stdin? true 45``` 46 47To test std in, pipe some text to the program 48 49```bash 50$ echo "test" | cargo run --example atty 51stdout? true 52stderr? true 53stdin? false 54``` 55 56To test std out, pipe the program to something 57 58```bash 59$ cargo run --example atty | grep std 60stdout? false 61stderr? true 62stdin? true 63``` 64 65To test std err, pipe the program to something redirecting std err 66 67```bash 68$ cargo run --example atty 2>&1 | grep std 69stdout? false 70stderr? false 71stdin? true 72``` 73 74Doug Tangren (softprops) 2015-2019 75