230925.2 · 19a08bee8a99e8c725b9781568013a9f686605a3
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.
reading declarations
Changes to crates/grep/examples/. All files
crates/grep/examples/simplegrep.rs
@@ -1,14 +1,15 @@-use std::env;-use std::error::Error;-use std::ffi::OsString;-use std::process;+use std::{env, error::Error, ffi::OsString, io::IsTerminal, process}; -use grep::cli;-use grep::printer::{ColorSpecs, StandardBuilder};-use grep::regex::RegexMatcher;-use grep::searcher::{BinaryDetection, SearcherBuilder};-use termcolor::ColorChoice;-use walkdir::WalkDir;+use {+ grep::{+ cli,+ printer::{ColorSpecs, StandardBuilder},+ regex::RegexMatcher,+ searcher::{BinaryDetection, SearcherBuilder},+ },+ termcolor::ColorChoice,+ walkdir::WalkDir,+}; fn main() { if let Err(err) = try_main() {@@ -36,7 +37,7 @@ fn search(pattern: &str, paths: &[OsString]) -> Result<(), Box<dyn Error>> { .build(); let mut printer = StandardBuilder::new() .color_specs(ColorSpecs::default_with_color())- .build(cli::stdout(if cli::is_tty_stdout() {+ .build(cli::stdout(if std::io::stdout().is_terminal() { ColorChoice::Auto } else { ColorChoice::Never