summaryrefslogtreecommitdiffstats
path: root/crates/core/args.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2023-09-20 14:42:03 -0400
committerAndrew Gallant <jamslam@gmail.com>2023-09-25 14:39:54 -0400
commit19a08bee8a99e8c725b9781568013a9f686605a3 (patch)
tree24cefa11626735b59072917d0822e90fc0c4417a /crates/core/args.rs
parent1a50324013708e3c73bfa986d273af2f8e8e3360 (diff)
cli: clean-up crate
This does a variety of polishing. 1. Deprecate the tty methods in favor of std's IsTerminal trait. 2. Trim down un-needed dependencies. 3. Use bstr to implement escaping. 4. Various aesthetic polishing. I'm doing this as prep work before adding more to this crate. And as part of a general effort toward reducing ripgrep's dependencies.
Diffstat (limited to 'crates/core/args.rs')
-rw-r--r--crates/core/args.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/core/args.rs b/crates/core/args.rs
index f3af1dab..9984a592 100644
--- a/crates/core/args.rs
+++ b/crates/core/args.rs
@@ -2,7 +2,7 @@ use std::cmp;
use std::env;
use std::ffi::{OsStr, OsString};
use std::fs;
-use std::io::{self, Write};
+use std::io::{self, IsTerminal, Write};
use std::path::{Path, PathBuf};
use std::process;
use std::str::FromStr;
@@ -976,7 +976,7 @@ impl ArgMatches {
} else if preference == "ansi" {
ColorChoice::AlwaysAnsi
} else if preference == "auto" {
- if cli::is_tty_stdout() || self.is_present("pretty") {
+ if std::io::stdout().is_terminal() || self.is_present("pretty") {
ColorChoice::Auto
} else {
ColorChoice::Never
@@ -1110,7 +1110,7 @@ impl ArgMatches {
if self.is_present("no-heading") || self.is_present("vimgrep") {
false
} else {
- cli::is_tty_stdout()
+ std::io::stdout().is_terminal()
|| self.is_present("heading")
|| self.is_present("pretty")
}
@@ -1178,7 +1178,7 @@ impl ArgMatches {
// generally want to show line numbers by default when printing to a
// tty for human consumption, except for one interesting case: when
// we're only searching stdin. This makes pipelines work as expected.
- (cli::is_tty_stdout() && !self.is_only_stdin(paths))
+ (std::io::stdout().is_terminal() && !self.is_only_stdin(paths))
|| self.is_present("line-number")
|| self.is_present("column")
|| self.is_present("pretty")