diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-01-19 10:15:56 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-01-19 10:44:30 -0500 |
commit | 7a6a40bae18f89bcfc6997479d7202d2c098e964 (patch) | |
tree | 2d75e646bd424e858570e728d370f26af6c0d6a6 /src | |
parent | 1e9ee2cc85da6f18b72ea554010810c317c31031 (diff) |
edition: move core ripgrep to Rust 2018
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 3 | ||||
-rw-r--r-- | src/args.rs | 24 | ||||
-rw-r--r-- | src/config.rs | 6 | ||||
-rw-r--r-- | src/main.rs | 14 | ||||
-rw-r--r-- | src/messages.rs | 4 | ||||
-rw-r--r-- | src/search.rs | 3 | ||||
-rw-r--r-- | src/subject.rs | 3 |
7 files changed, 26 insertions, 31 deletions
@@ -9,7 +9,8 @@ // is where we read clap's configuration from the end user's arguments and turn // it into a ripgrep-specific configuration type that is not coupled with clap. -use clap::{self, App, AppSettings}; +use clap::{self, App, AppSettings, crate_authors, crate_version}; +use lazy_static::lazy_static; const ABOUT: &str = " ripgrep (rg) recursively searches your current directory for a regex pattern. diff --git a/src/args.rs b/src/args.rs index 623a230c..70af9df1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -34,20 +34,22 @@ use ignore::types::{FileTypeDef, Types, TypesBuilder}; use ignore::{Walk, WalkBuilder, WalkParallel}; use log; use num_cpus; -use path_printer::{PathPrinter, PathPrinterBuilder}; use regex; use termcolor::{ WriteColor, BufferWriter, ColorChoice, }; -use app; -use config; -use logger::Logger; -use messages::{set_messages, set_ignore_messages}; -use search::{PatternMatcher, Printer, SearchWorker, SearchWorkerBuilder}; -use subject::SubjectBuilder; -use Result; +use crate::app; +use crate::config; +use crate::logger::Logger; +use crate::messages::{set_messages, set_ignore_messages}; +use crate::path_printer::{PathPrinter, PathPrinterBuilder}; +use crate::search::{ + PatternMatcher, Printer, SearchWorker, SearchWorkerBuilder, +}; +use crate::subject::SubjectBuilder; +use crate::Result; /// The command that ripgrep should execute based on the command line /// configuration. @@ -491,7 +493,9 @@ impl ArgMatches { fn reconfigure(self) -> ArgMatches { // If the end user says no config, then respect it. if self.is_present("no-config") { - debug!("not reading config files because --no-config is present"); + log::debug!( + "not reading config files because --no-config is present" + ); return self; } // If the user wants ripgrep to use a config file, then parse args @@ -505,7 +509,7 @@ impl ArgMatches { args.insert(0, bin); } args.extend(cliargs); - debug!("final argv: {:?}", args); + log::debug!("final argv: {:?}", args); ArgMatches::new(app::app().get_matches_from(args)) } diff --git a/src/config.rs b/src/config.rs index eade0cca..f10c5a86 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,7 +9,9 @@ use std::io::{self, BufRead}; use std::ffi::OsString; use std::path::{Path, PathBuf}; -use Result; +use log; + +use crate::Result; /// Return a sequence of arguments derived from ripgrep rc configuration files. pub fn args() -> Vec<OsString> { @@ -34,7 +36,7 @@ pub fn args() -> Vec<OsString> { message!("{}:{}", config_path.display(), err); } } - debug!( + log::debug!( "{}: arguments loaded from config file: {:?}", config_path.display(), args diff --git a/src/main.rs b/src/main.rs index bcadc8a1..274a1fe2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,3 @@ -#[macro_use] -extern crate clap; -extern crate grep; -extern crate ignore; -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; -extern crate num_cpus; -extern crate regex; -#[macro_use] -extern crate serde_json; -extern crate termcolor; - use std::io::{self, Write}; use std::process; use std::sync::{Arc, Mutex}; diff --git a/src/messages.rs b/src/messages.rs index 2016ff64..21ca109d 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -6,7 +6,7 @@ static IGNORE_MESSAGES: AtomicBool = ATOMIC_BOOL_INIT; #[macro_export] macro_rules! message { ($($tt:tt)*) => { - if ::messages::messages() { + if crate::messages::messages() { eprintln!($($tt)*); } } @@ -15,7 +15,7 @@ macro_rules! message { #[macro_export] macro_rules! ignore_message { ($($tt:tt)*) => { - if ::messages::messages() && ::messages::ignore_messages() { + if crate::messages::messages() && crate::messages::ignore_messages() { eprintln!($($tt)*); } } diff --git a/src/search.rs b/src/search.rs index 9baf513f..048f882b 100644 --- a/src/search.rs +++ b/src/search.rs @@ -13,9 +13,10 @@ use grep::regex::{RegexMatcher as RustRegexMatcher}; use grep::searcher::Searcher; use ignore::overrides::Override; use serde_json as json; +use serde_json::json; use termcolor::WriteColor; -use subject::Subject; +use crate::subject::Subject; /// The configuration for the search worker. Among a few other things, the /// configuration primarily controls the way we show search results to users diff --git a/src/subject.rs b/src/subject.rs index f323ef08..82cddbd9 100644 --- a/src/subject.rs +++ b/src/subject.rs @@ -1,6 +1,7 @@ use std::path::Path; use ignore::{self, DirEntry}; +use log; /// A configuration for describing how subjects should be built. #[derive(Clone, Debug)] @@ -79,7 +80,7 @@ impl SubjectBuilder { // directory. Otherwise, emitting messages for directories is just // noisy. if !subj.is_dir() { - debug!( + log::debug!( "ignoring {}: failed to pass subject filter: \ file type: {:?}, metadata: {:?}", subj.dent.path().display(), |