Updates and preparations for v5.0
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by David Peter · parent 15a3ca0 · Browse files · 10 files·+26 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+26 added−21 removed
- other:+26 added−21 removed
Provenance
- Commit
e9cf8af- Tree
26cb51f- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
15a3ca0
10 files changed+26 added−21 removed
modified:src/exec/job.rs+1 added-1 removed
36 unmodified lines37 // Drop the lock so that other threads can read from the the receiver.38 drop(lock);39 // Generate a command to store within the buffer, and execute the command.40 // Note that the `then_execute()` method will clear the buffer for us.41- cmd.generate(buffer, &value, out_perm.clone())41+ cmd.generate(buffer, &value, Arc::clone(&out_perm))42 .then_execute();43 }44 }modified:src/exec/ticket.rs+1 added-1 removed
15 unmodified lines16 /// preferred shell of choice for execution. Windows will simply use `cmd`.17 static ref COMMAND: (String, &'static str) = if cfg!(target_os = "windows") {18 ("cmd".into(), "/C")19 } else {20- (env::var("SHELL").unwrap_or("/bin/sh".into()), "-c")20+ (env::var("SHELL").unwrap_or_else(|_| "/bin/sh".into()), "-c")21 };22 }23 24 /// A state that offers access to executing a generated command.117 unmodified linesmodified:src/lscolors/mod.rs+1 added-1 removed
15 unmodified lines16 17 /// Maps filenames to ANSI colors / styles.18 pub type FilenameStyles = HashMap<String, Style>;19 20-const LS_CODES: &'static [&'static str] = &[20+const LS_CODES: &[&str] = &[21 "no",22 "no",23 "fi",24 "rs",242 unmodified linesmodified:src/app.rs+9 added-4 removed
101 unmodified lines102 .long("max-buffer-time")103 .takes_value(true)104 .hidden(true),105 )106- .arg(arg("exec").long("exec").short("x").takes_value(true))106+ .arg(107+ arg("exec")108+ .long("exec")109+ .short("x")110+ .takes_value(true)111+ .value_name("cmd"),112+ )113 .arg(arg("pattern"))114 .arg(arg("path"))115 }116 41 unmodified lines158 'f' or 'file': regular files\n \159 'd' or 'directory': directories\n \160 'l' or 'symlink': symbolic links");161 doc!(h, "exec"156- , "Execute each discovered path using the argument that follows as the command expression."157- , "Execute each discovered path using the argument that follows as the command \158- expression.\n \162+ , "Execute the given command for each search result"163+ , "Execute the given command for each search result.\n\164 The following are valid tokens that can be used within the expression for generating \165 commands:\n \166 '{}': places the input in the location of this token\n \167 '{.}': removes the extension from the input\n \32 unmodified linesmodified:src/internal.rs+1 added-1 removed
100 unmodified lines101 ranges.iter().any(|r| {102 r.start.is_uppercase() || r.end.is_uppercase()103 })104 }105- Expr::Group { ref e, .. } => expr_has_uppercase_char(e),105+ Expr::Group { ref e, .. } |106 Expr::Repeat { ref e, .. } => expr_has_uppercase_char(e),107 Expr::Concat(ref es) => es.iter().any(expr_has_uppercase_char),108 Expr::Alternate(ref es) => es.iter().any(expr_has_uppercase_char),109 _ => false,2 unmodified linesmodified:src/main.rs+2 added-2 removed
50 unmodified lines51 let pattern = matches.value_of("pattern").unwrap_or(&empty_pattern);52 53 // Get the current working directory54 let current_dir = Path::new(".");55- if !fshelper::is_dir(¤t_dir) {55+ if !fshelper::is_dir(current_dir) {56 error("Error: could not get current directory.");57 }58 59 // Get the root directory for the search42 unmodified lines102 } else {103 None104 };105 106- let command = matches.value_of("exec").map(|x| TokenizedCommand::new(&x));106+ let command = matches.value_of("exec").map(|x| TokenizedCommand::new(x));107 108 let config = FdOptions {109 case_sensitive,110 search_full_path: matches.is_present("full-path"),43 unmodified linesmodified:src/walk.rs+5 added-5 removed
74 unmodified lines75 76 // Each spawned job will store it's thread handle in here.77 let mut handles = Vec::with_capacity(threads);78 for _ in 0..threads {79- let rx = shared_rx.clone();80- let cmd = cmd.clone();81- let out_perm = out_perm.clone();79+ let rx = Arc::clone(&shared_rx);80+ let cmd = Arc::clone(&cmd);81+ let out_perm = Arc::clone(&out_perm);82 83 // Spawn a job thread that will listen for and execute inputs.84 let handle = thread::spawn(move || exec::job(rx, cmd, out_perm));85 26 unmodified lines112 // Have we reached the maximum time?113 if time::Instant::now() - start > max_buffer_time {114 // Flush the buffer115 for v in &buffer {116- output::print_entry(&v, &rx_config);116+ output::print_entry(v, &rx_config);117 }118 buffer.clear();119 120 // Start streaming66 unmodified lines187 }188 }189 190 let search_str_o = if config.search_full_path {191- match fshelper::path_absolute_form(&entry_path) {191+ match fshelper::path_absolute_form(entry_path) {192 Ok(path_abs_buf) => Some(path_abs_buf.to_string_lossy().into_owned().into()),193 Err(_) => error("Error: unable to get full path."),194 }195 } else {21 unmodified linesmodified:Cargo.lock+1 added-1 removed
1 [root]2 name = "fd-find"3-version = "4.0.0"3+version = "5.0.0"4 dependencies = [5 "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",6 "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",7 "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)",369 unmodified linesmodified:Cargo.toml+1 added-1 removed
14 unmodified lines15 license = "MIT/Apache-2.0"16 name = "fd-find"17 readme = "README.md"18 repository = "https://github.com/sharkdp/fd"19-version = "4.0.0"19+version = "5.0.0"20 21 [[bin]]22 name = "fd"23 path = "src/main.rs"28 unmodified linesmodified:README.md+4 added-4 removed
169 unmodified lines170 FLAGS:171 -H, --hidden Search hidden files and directories172 -I, --no-ignore Do not respect .(git)ignore files173 -s, --case-sensitive Case-sensitive search (default: smart case)174+ -i, --ignore-case Case-insensitive search (default: smart case)175 -a, --absolute-path Show absolute instead of relative paths176 -L, --follow Follow symbolic links177 -p, --full-path Search full path (default: file-/dirname only)178 -0, --print0 Separate results by the null character3 unmodified lines182 OPTIONS:183 -d, --max-depth <depth> Set maximum search depth (default: none)184 -t, --type <filetype> Filter by type: f(ile), d(irectory), (sym)l(ink)185 -e, --extension <ext> Filter by file extension185- -c, --color <when> When to use color in the output:186- never, auto, always (default: auto)187- -j, --threads <num> Set number of threads to use for searching:188- (default: number of available CPU cores)186+ -c, --color <when> When to use colors: never, *auto*, always187+ -j, --threads <num> Set number of threads to use for searching & executing188+ -x, --exec <cmd> Execute the given command for each search result189 190 ARGS:191 <pattern> the search pattern, a regular expression (optional)192 <path> the root directory for the filesystem search (optional)162 unmodified lines