Crate isatty[][src]

This crate provides the following three functions:

fn stdin_isatty() -> bool
fn stdout_isatty() -> bool
fn stderr_isatty() -> bool

On Linux and Mac they are implemented with libc::isatty. On Windows they are implemented with consoleapi::GetConsoleMode. On Redox they are implemented with termion::is_tty.

The stdin_isatty function is not yet implemented for Windows. If you need it, please check dtolnay/isatty#1 and contribute an implementation!

Usage

Cargo.toml

[dependencies]
isatty = "0.1"

src/main.rs

extern crate isatty;
use isatty::{stdin_isatty, stdout_isatty, stderr_isatty};

fn main() {
    println!("stdin: {}", stdin_isatty());
    println!("stdout: {}", stdout_isatty());
    println!("stderr: {}", stderr_isatty());
}

Functions

stderr_isatty
stdin_isatty
stdout_isatty