Detect interactive terminal, closes #11
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by sharkdp · parent e43353a · Browse files · 3 files·+23 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+23 added−7 removed
- other:+23 added−7 removed
Provenance
- Commit
b4a252a- Tree
eeaf398- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
e43353a
3 files changed+23 added−7 removed
modified:src/main.rs+10 added-7 removed
1-extern crate walkdir;2-extern crate regex;3-extern crate getopts;1 extern crate ansi_term;2+extern crate getopts;3+extern crate isatty;4+extern crate regex;5+extern crate walkdir;6 7 use std::env;8 use std::error::Error;9 use std::ffi::OsStr;10 use std::io::Write;11 use std::path::Path;12 use std::process;13 13-use walkdir::{WalkDir, DirEntry, WalkDirIterator};14-use regex::{Regex, RegexBuilder};15-use getopts::Options;14 use ansi_term::Colour;15+use getopts::Options;16+use isatty::stdout_isatty;17+use regex::{Regex, RegexBuilder};18+use walkdir::{WalkDir, DirEntry, WalkDirIterator};19 20 struct FdOptions {21 case_sensitive: bool,22 search_full_path: bool,108 unmodified lines131 case_sensitive: matches.opt_present("sensitive") ||132 pattern.chars().any(char::is_uppercase),133 search_full_path: !matches.opt_present("filename"),134 search_hidden: matches.opt_present("hidden"),133- colored: !matches.opt_present("no-color"),135+ colored: !matches.opt_present("no-color") &&136+ stdout_isatty(),137 follow_links: matches.opt_present("follow"),138 max_depth:139 matches.opt_str("max-depth")140 .and_then(|ds| usize::from_str_radix(&ds, 10).ok())10 unmodified linesmodified:Cargo.lock+12 added
2 unmodified lines3 version = "0.1.0"4 dependencies = [5 "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",6 "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",7+ "isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",8 "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",9 "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",10 ]11 15 unmodified lines27 version = "0.2.14"28 source = "registry+https://github.com/rust-lang/crates.io-index"29 30 [[package]]31+name = "isatty"32+version = "0.1.3"33+source = "registry+https://github.com/rust-lang/crates.io-index"34+dependencies = [35+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",36+ "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",37+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",38+]39+40+[[package]]41 name = "kernel32-sys"42 version = "0.2.2"43 source = "registry+https://github.com/rust-lang/crates.io-index"44 dependencies = [99 unmodified lines144 [metadata]145 "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"146 "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"147 "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"148+"checksum isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fa500db770a99afe2a0f2229be2a3d09c7ed9d7e4e8440bf71253141994e240f"149 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"150 "checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502"151 "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"152 "checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01"10 unmodified linesmodified:Cargo.toml+1 added
6 unmodified lines78910116 unmodified linesgetopts = "0.2"regex = "0.2"walkdir = "1"ansi_term = "0.9"isatty = "0.1"