atty

are you or are you not a tty?

Latest version: 0.2.14 registry icon
Maintenance score
15
Safety score
0
Popularity score
76
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.2.14 0 0 2 0 0
0.2.13 0 0 2 0 0
0.2.12 0 0 2 0 0
0.2.11 0 0 2 0 0
0.2.10 0 0 2 0 0
0.2.9 0 0 2 0 0
0.2.8 0 0 2 0 0
0.2.7 0 0 2 0 0
0.2.6 0 0 2 0 0
0.2.4 0 0 2 0 0
0.2.3 0 0 2 0 0
0.2.2 0 0 2 0 0
0.2.1 0 0 2 0 0
0.2.0 0 0 2 0 0
0.1.2 0 0 2 0 0
0.1.1 0 0 2 0 0
0.1.0 0 0 2 0 0

Stability
Latest release:

0.2.14 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



atty

[!WARNING] This is crate is no longer maintained and users are encouraged to prefer the equivalant functionality of std.io.IsTerminal, introduced in Rust 1.70.0

Thank you for your support!

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