softprops/atty


are you or are you not a tty?

License: MIT

Language: Rust

Keywords: library, rust, rust-library, tty


atty

Build Status Build status Coverage Status crates.io Released API docs Master API docs

are you or are you not a tty?

install

Add the following to your Cargo.toml

[dependencies]
atty = "0.2"

usage

use atty::Stream;

fn main() {
  if atty::is(Stream::Stdout) {
    println!("I'm a terminal");
  } else {
    println!("I'm not");
  }
}

testing

This library has been unit tested on both unix and windows platforms (via appveyor).

A simple example program is provided in this repo to test various tty's. By default.

It prints

$ cargo run --example atty
stdout? true
stderr? true
stdin? true

To test std in, pipe some text to the program

$ echo "test" | cargo run --example atty
stdout? true
stderr? true
stdin? false

To test std out, pipe the program to something

$ cargo run --example atty | grep std
stdout? false
stderr? true
stdin? true

To test std err, pipe the program to something redirecting std err

$ cargo run --example atty 2>&1 | grep std
stdout? false
stderr? false
stdin? true

Doug Tangren (softprops) 2015-2019

Project Statistics

Sourcerank 15
Repository Size 787 KB
Stars 98
Forks 17
Watchers 8
Open issues 8
Dependencies 0
Contributors 11
Tags 18
Created
Last updated
Last pushed

Top Contributors See all

Doug Tangren Andrew Gallant Jay Alex Crichton Ian Douglas Scott Alexander Bulaev Yurii Rashkovskii Xavier L'Heureux Guillaume Martres Eric Huss Igor Gnatenko

Packages Referencing this Repo

atty
A simple interface for querying atty
Latest release 0.2.13 - Updated - 98 stars

Recent Tags See all

0.2.13 July 16, 2019
0.2.12 July 11, 2019
0.2.11 July 22, 2018
0.2.10 April 30, 2018
0.2.9 April 21, 2018
0.2.9 April 21, 2018
0.2.8 March 07, 2018
0.2.7 March 07, 2018
0.2.6 December 20, 2017
0.2.4 December 20, 2017
0.2.4 December 20, 2017
0.2.3 September 30, 2017
0.2.2 January 15, 2017
0.2.1 September 12, 2016
0.2.0 September 12, 2016

Interesting Forks See all

BurntSushi/atty
are you or are you not a tty?
Rust - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-07-16 03:14:38 UTC

Login to resync this repository