Skip to content
Myr

Add alias -1 for --max-results=1

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

authored by Danny Mösch · committed by David Peter · parent 95eae00 · Browse files · 5 files+24 added−6 removed
This commit

State

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

Diff stats

5 files+24 added−6 removed

  • tests:+9 added−5 removed
  • other:+15 added−1 removed

5 files+24 added−6 removed

modified:doc/fd.1+3 added
87 unmodified lines
88.TP89.B \-\-max\-results count90Limit the number of search results to 'count' and quit immediately.91.TP92.B \-193Limit the search to a single result and quit immediately. This is an alias for '--max-results=1'.94.TP95.B \-\-show-errors96Enable the display of filesystem errors for situations such as insufficient97permissions or dead symlinks.98.TP
182 unmodified lines
modified:src/app.rs+9 added
414 unmodified lines
415 .hidden_short_help(true)416 .long_help("Limit the number of search results to 'count' and quit immediately."),417 )418 .arg(419 Arg::with_name("max-one-result")420 .short("1")421 .hidden_short_help(true)422 .overrides_with("max-results")423 .conflicts_with_all(&["exec", "exec-batch"])424 .long_help("Limit the search to a single result and quit immediately. \425 This is an alias for '--max-results=1'.")426 )427 .arg(428 Arg::with_name("show-errors")429 .long("show-errors")430 .hidden_short_help(true)431 .overrides_with("show-errors")
80 unmodified lines
modified:src/main.rs+2 added-1 removed
293 unmodified lines
294 path_separator,295 max_results: matches296 .value_of("max-results")297 .and_then(|n| usize::from_str_radix(n, 10).ok())298 .filter(|&n| n != 0),298 .filter(|&n| n != 0)299 .or_else(|| if matches.is_present("max-one-result") { Some(1) } else { None }),300 };301302 let re = RegexBuilder::new(&pattern_regex)303 .case_insensitive(!config.case_sensitive)
26 unmodified lines
modified:tests/tests.rs+9 added-5 removed
1456 unmodified lines
1457 one/two/c.foo",1458 );14591460 // Limited to one result. We could find either C.Foo2 or c.foo1461 let assert_just_one_result_with_option = |option| {1461 let output = te.assert_success_and_get_output(".", &["--max-results=1", "c.foo"]);1462 let stdout = String::from_utf8_lossy(&output.stdout);1463 let stdout = stdout.trim();1464 let stdout = stdout.replace(&std::path::MAIN_SEPARATOR.to_string(), "/");1465 assert!(stdout == "one/two/C.Foo2" || stdout == "one/two/c.foo");1462 let output = te.assert_success_and_get_output(".", &[option, "c.foo"]);1463 let stdout = String::from_utf8_lossy(&output.stdout)1464 .trim()1465 .replace(&std::path::MAIN_SEPARATOR.to_string(), "/");1466 assert!(stdout == "one/two/C.Foo2" || stdout == "one/two/c.foo");1467 };1468 assert_just_one_result_with_option("--max-results=1");1469 assert_just_one_result_with_option("-1");1470}14711472/// Filenames with non-utf8 paths are passed to the executed program unchanged1473///
43 unmodified lines
modified:CHANGELOG.md+1 added
10 unmodified lines
11- Add a new `--max-results=<count>` option to limit the number of search results, see #472 and #47612 This can be useful to speed up searches in cases where you know that there are only N results.13 Using this option is also (slightly) faster than piping to `head -n <count>` where `fd` can only14 exit when it finds the search results `<count> + 1`.15- Add the alias `-1` for `--max-results=1`, see #561. (@SimplyDanny).16- Support additional ANSI font styles in `LS_COLORS`: faint, slow blink, rapid blink, dimmed, hidden and strikethrough.1718## Bugfixes19
409 unmodified lines