diff --git a/Cargo.lock b/Cargo.lock index 0205dd5..cf14d81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "fd-find" -version = "4.0.0" +version = "5.0.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 969160a..4e51db4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = "MIT/Apache-2.0" name = "fd-find" readme = "README.md" repository = "https://github.com/sharkdp/fd" -version = "4.0.0" +version = "5.0.0" [[bin]] name = "fd" diff --git a/README.md b/README.md index 003c640..d580079 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ FLAGS: -H, --hidden Search hidden files and directories -I, --no-ignore Do not respect .(git)ignore files -s, --case-sensitive Case-sensitive search (default: smart case) + -i, --ignore-case Case-insensitive search (default: smart case) -a, --absolute-path Show absolute instead of relative paths -L, --follow Follow symbolic links -p, --full-path Search full path (default: file-/dirname only) @@ -182,10 +183,9 @@ OPTIONS: -d, --max-depth Set maximum search depth (default: none) -t, --type Filter by type: f(ile), d(irectory), (sym)l(ink) -e, --extension Filter by file extension - -c, --color When to use color in the output: - never, auto, always (default: auto) - -j, --threads Set number of threads to use for searching: - (default: number of available CPU cores) + -c, --color When to use colors: never, *auto*, always + -j, --threads Set number of threads to use for searching & executing + -x, --exec Execute the given command for each search result ARGS: the search pattern, a regular expression (optional) diff --git a/src/app.rs b/src/app.rs index d26a125..991036b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -103,7 +103,13 @@ pub fn build_app() -> App<'static, 'static> { .takes_value(true) .hidden(true), ) - .arg(arg("exec").long("exec").short("x").takes_value(true)) + .arg( + arg("exec") + .long("exec") + .short("x") + .takes_value(true) + .value_name("cmd"), + ) .arg(arg("pattern")) .arg(arg("path")) } @@ -153,9 +159,8 @@ fn usage() -> HashMap<&'static str, Help> { 'd' or 'directory': directories\n \ 'l' or 'symlink': symbolic links"); doc!(h, "exec" - , "Execute each discovered path using the argument that follows as the command expression." - , "Execute each discovered path using the argument that follows as the command \ - expression.\n \ + , "Execute the given command for each search result" + , "Execute the given command for each search result.\n\ The following are valid tokens that can be used within the expression for generating \ commands:\n \ '{}': places the input in the location of this token\n \ diff --git a/src/exec/job.rs b/src/exec/job.rs index 389fc67..4ca518e 100644 --- a/src/exec/job.rs +++ b/src/exec/job.rs @@ -38,7 +38,7 @@ pub fn job( drop(lock); // Generate a command to store within the buffer, and execute the command. // Note that the `then_execute()` method will clear the buffer for us. - cmd.generate(buffer, &value, out_perm.clone()) + cmd.generate(buffer, &value, Arc::clone(&out_perm)) .then_execute(); } } diff --git a/src/exec/ticket.rs b/src/exec/ticket.rs index 75d4bf6..7e3dcaf 100644 --- a/src/exec/ticket.rs +++ b/src/exec/ticket.rs @@ -17,7 +17,7 @@ lazy_static! { static ref COMMAND: (String, &'static str) = if cfg!(target_os = "windows") { ("cmd".into(), "/C") } else { - (env::var("SHELL").unwrap_or("/bin/sh".into()), "-c") + (env::var("SHELL").unwrap_or_else(|_| "/bin/sh".into()), "-c") }; } diff --git a/src/internal.rs b/src/internal.rs index 65c72aa..a4c21f0 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -102,7 +102,7 @@ fn expr_has_uppercase_char(expr: &Expr) -> bool { r.start.is_uppercase() || r.end.is_uppercase() }) } - Expr::Group { ref e, .. } => expr_has_uppercase_char(e), + Expr::Group { ref e, .. } | Expr::Repeat { ref e, .. } => expr_has_uppercase_char(e), Expr::Concat(ref es) => es.iter().any(expr_has_uppercase_char), Expr::Alternate(ref es) => es.iter().any(expr_has_uppercase_char), diff --git a/src/lscolors/mod.rs b/src/lscolors/mod.rs index a6afa65..65ac193 100644 --- a/src/lscolors/mod.rs +++ b/src/lscolors/mod.rs @@ -17,7 +17,7 @@ pub type ExtensionStyles = HashMap; /// Maps filenames to ANSI colors / styles. pub type FilenameStyles = HashMap; -const LS_CODES: &'static [&'static str] = &[ +const LS_CODES: &[&str] = &[ "no", "no", "fi", diff --git a/src/main.rs b/src/main.rs index b39224b..736a9f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,7 @@ fn main() { // Get the current working directory let current_dir = Path::new("."); - if !fshelper::is_dir(¤t_dir) { + if !fshelper::is_dir(current_dir) { error("Error: could not get current directory."); } @@ -103,7 +103,7 @@ fn main() { None }; - let command = matches.value_of("exec").map(|x| TokenizedCommand::new(&x)); + let command = matches.value_of("exec").map(|x| TokenizedCommand::new(x)); let config = FdOptions { case_sensitive, diff --git a/src/walk.rs b/src/walk.rs index 5689042..3a399e8 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -76,9 +76,9 @@ pub fn scan(root: &Path, pattern: Arc, config: Arc) { // Each spawned job will store it's thread handle in here. let mut handles = Vec::with_capacity(threads); for _ in 0..threads { - let rx = shared_rx.clone(); - let cmd = cmd.clone(); - let out_perm = out_perm.clone(); + let rx = Arc::clone(&shared_rx); + let cmd = Arc::clone(&cmd); + let out_perm = Arc::clone(&out_perm); // Spawn a job thread that will listen for and execute inputs. let handle = thread::spawn(move || exec::job(rx, cmd, out_perm)); @@ -113,7 +113,7 @@ pub fn scan(root: &Path, pattern: Arc, config: Arc) { if time::Instant::now() - start > max_buffer_time { // Flush the buffer for v in &buffer { - output::print_entry(&v, &rx_config); + output::print_entry(v, &rx_config); } buffer.clear(); @@ -188,7 +188,7 @@ pub fn scan(root: &Path, pattern: Arc, config: Arc) { } let search_str_o = if config.search_full_path { - match fshelper::path_absolute_form(&entry_path) { + match fshelper::path_absolute_form(entry_path) { Ok(path_abs_buf) => Some(path_abs_buf.to_string_lossy().into_owned().into()), Err(_) => error("Error: unable to get full path."), }