Skip to content
Myr

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

8 files+57 added−0 removed

modified:contrib/completion/_fd+3 added
100 unmodified lines
101 '!(--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'104105 + prune # pruning106 "--prune[don't traverse into matching directories]"107108 + 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 lines
modified:doc/fd.1+3 added
113 unmodified lines
114.TP115.BI "\-\-exact\-depth " d116Only show search results at the exact given depth. This is an alias for '--min-depth <depth> --max-depth <depth>'.117.TP118.B \-\-prune119Do not traverse into matching directories.120.TP121.BI "\-t, \-\-type " filetype122Filter search by type:123.RS124.IP "f, file"
202 unmodified lines
modified:src/app.rs+7 added
214 unmodified lines
215 '--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 lines
modified:src/main.rs+1 added
321 unmodified lines
322 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 lines
modified:src/options.rs+3 added
46 unmodified lines
4748 /// The minimum depth for reported entries, or `None`.49 pub min_depth: Option<usize>,5051 /// Whether to stop traversing into matching directories.52 pub prune: bool,5354 /// The number of threads to use.55 pub threads: usize,5657 /// Time to buffer results internally before streaming to the console. This is useful to
48 unmodified lines
modified:src/walk.rs+5 added
492 unmodified lines
493 if send_result.is_err() {494 return ignore::WalkState::Quit;495 }496497 // Apply pruning.498 if config.prune {499 return ignore::WalkState::Skip;500 }501502 ignore::WalkState::Continue503 })504 });505}
modified:tests/tests.rs+34 added
756 unmodified lines
757 one/two/three",758 );759}760761/// Pruning (--prune)762#[test]763fn 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 ];772773 let te = TestEnv::new(dirs, files);774775 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 );785786 te.assert_output(787 &["--prune", "foo"],788 "foo789 bar/foo790 bar/foo.file791 baz/foo.file",792 );793}794795/// Absolute paths (--absolute-path)796#[test]797fn test_absolute_path() {798 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);
849 unmodified lines
modified:CHANGELOG.md+1 added
1 unmodified line
23## Features45- Improved the usability of the time-based options, see #624 and #645 (@gorogoroumaru)6- Add new `--prune` flag, see #535 (@reima)78## Bugfixes910- Disable jemalloc on Android, see #662
480 unmodified lines