Skip to content
Myr

Configurable search depth, closes #13

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 7076dcb · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • other:+9 added−2 removed

1 file+9 added−2 removed

modified:src/main.rs+9 added-2 removed
18 unmodified lines
19 case_sensitive: bool,20 search_full_path: bool,21 search_hidden: bool,22 follow_links: bool,23 colored: bool23 colored: bool,24 max_depth: usize25}2627/// Print a search result to the console.28fn print_entry(entry: &DirEntry, path_str: &str, config: &FdOptions) {
21 unmodified lines
50/// matching the pattern.51fn scan(root: &Path, pattern: &Regex, config: &FdOptions) {52 let walker = WalkDir::new(root)53 .follow_links(config.follow_links)54 .max_depth(config.max_depth)55 .into_iter()56 .filter_entry(|e| config.search_hidden || !is_hidden(e))57 .filter_map(|e| e.ok())58 .filter(|e| e.path() != root);
40 unmodified lines
99 opts.optflag("", "hidden",100 "search hidden files/directories (default: off)");101 opts.optflag("F", "follow", "follow symlinks (default: off)");102 opts.optflag("n", "no-color", "do not colorize output");103 opts.optopt("d", "max-depth", "maximum search depth", "DEPTH");104105 let matches = match opts.parse(&args[1..]) {106 Ok(m) => m,107 Err(e) => error(e.description())
22 unmodified lines
130 pattern.chars().any(char::is_uppercase),131 search_full_path: !matches.opt_present("filename"),132 search_hidden: matches.opt_present("hidden"),133 colored: !matches.opt_present("no-color"),131 follow_links: matches.opt_present("follow")134 follow_links: matches.opt_present("follow"),135 max_depth:136 matches.opt_str("max-depth")137 .and_then(|ds| usize::from_str_radix(&ds, 10).ok())138 .unwrap_or(25)139 };140141 match RegexBuilder::new(pattern)142 .case_insensitive(!config.case_sensitive)
5 unmodified lines