Add --prune flag
Before adoption: this commit came in with the history the project adopted, so no landing records it.
closes #535
authored by Matthias Reitinger · committed by GitHub · parent 06eb231 · Browse files · 8 files·+57 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+57 added−0 removed
- tests:+34 added−0 removed
- other:+23 added−0 removed
Provenance
- Commit
ec4cc98- Tree
9de2976- Author
Matthias Reitinger <reima@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
06eb231
8 files changed+57 added−0 removed
modified:contrib/completion/_fd+3 added
100 unmodified lines101 '!(--exact-depth -d --max-depth)--maxdepth:depth'102 '(--exact-depth --min-depth)--min-depth=[set directory depth to descend before start searching]:depth'103 '(--exact-depth -d --max-depth --maxdepth --min-depth)--exact-depth=[only search at the exact given directory depth]:depth'104 105+ + prune # pruning106+ "--prune[don't traverse into matching directories]"107+108 + filter-misc # filter search109 '*'{-t+,--type=}"[filter search by type]:type:(($fd_types))"110 '*'{-e+,--extension=}'[filter search by file extension]:extension'111 '*'{-E+,--exclude=}'[exclude files/directories that match the given glob pattern]:glob pattern'157 unmodified linesmodified:doc/fd.1+3 added
113 unmodified lines114 .TP115 .BI "\-\-exact\-depth " d116 Only show search results at the exact given depth. This is an alias for '--min-depth <depth> --max-depth <depth>'.117 .TP118+.B \-\-prune119+Do not traverse into matching directories.120+.TP121 .BI "\-t, \-\-type " filetype122 Filter search by type:123 .RS124 .IP "f, file"202 unmodified linesmodified:src/app.rs+7 added
214 unmodified lines215 '--min-depth <depth> --max-depth <depth>'.",216 ),217 )218 .arg(219+ Arg::with_name("prune")220+ .long("prune")221+ .conflicts_with_all(&["size", "exact-depth"])222+ .hidden_short_help(true)223+ .long_help("Do not traverse into matching directories.")224+ )225+ .arg(226 Arg::with_name("file-type")227 .long("type")228 .short("t")229 .multiple(true)352 unmodified linesmodified:src/main.rs+1 added
321 unmodified lines322 min_depth: matches323 .value_of("min-depth")324 .or_else(|| matches.value_of("exact-depth"))325 .and_then(|n| usize::from_str_radix(n, 10).ok()),326+ prune: matches.is_present("prune"),327 threads: std::cmp::max(328 matches329 .value_of("threads")330 .and_then(|n| usize::from_str_radix(n, 10).ok())102 unmodified linesmodified:src/options.rs+3 added
46 unmodified lines47 48 /// The minimum depth for reported entries, or `None`.49 pub min_depth: Option<usize>,50 51+ /// Whether to stop traversing into matching directories.52+ pub prune: bool,53+54 /// The number of threads to use.55 pub threads: usize,56 57 /// Time to buffer results internally before streaming to the console. This is useful to48 unmodified linesmodified:src/walk.rs+5 added
492 unmodified lines493 if send_result.is_err() {494 return ignore::WalkState::Quit;495 }496 497+ // Apply pruning.498+ if config.prune {499+ return ignore::WalkState::Skip;500+ }501+502 ignore::WalkState::Continue503 })504 });505 }modified:tests/tests.rs+34 added
756 unmodified lines757 one/two/three",758 );759 }760 761+/// Pruning (--prune)762+#[test]763+fn test_prune() {764+ let dirs = &["foo/bar", "bar/foo", "baz"];765+ let files = &[766+ "foo/foo.file",767+ "foo/bar/foo.file",768+ "bar/foo.file",769+ "bar/foo/foo.file",770+ "baz/foo.file",771+ ];772+773+ let te = TestEnv::new(dirs, files);774+775+ te.assert_output(776+ &["foo"],777+ "foo778+ foo/foo.file779+ foo/bar/foo.file780+ bar/foo.file781+ bar/foo782+ bar/foo/foo.file783+ baz/foo.file",784+ );785+786+ te.assert_output(787+ &["--prune", "foo"],788+ "foo789+ bar/foo790+ bar/foo.file791+ baz/foo.file",792+ );793+}794+795 /// Absolute paths (--absolute-path)796 #[test]797 fn test_absolute_path() {798 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);849 unmodified linesmodified:CHANGELOG.md+1 added
1 unmodified line2 3 ## Features4 5 - Improved the usability of the time-based options, see #624 and #645 (@gorogoroumaru)6+- Add new `--prune` flag, see #535 (@reima)7 8 ## Bugfixes9 10 - Disable jemalloc on Android, see #662480 unmodified lines