Merge pull request #1394 from final-israel/make_max_results_one_conflict_with_exec

Making `-1` conflict with `--exec` and making `max-results` override `-1`
This commit is contained in:
Thayne McCombs 2023-10-05 10:27:43 -06:00 committed by GitHub
commit fc240f7b2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -26,7 +26,7 @@ use crate::filter::SizeFilter;
max_term_width = 98,
args_override_self = true,
group(ArgGroup::new("execs").args(&["exec", "exec_batch", "list_details"]).conflicts_with_all(&[
"max_results", "has_results", "count"])),
"max_results", "has_results", "count", "max_one_result"])),
)]
pub struct Opts {
/// Include hidden directories and files in the search results (default:
@ -505,6 +505,7 @@ pub struct Opts {
long,
value_name = "count",
hide_short_help = true,
overrides_with("max_one_result"),
help = "Limit the number of search results",
long_help
)]

View File

@ -2384,6 +2384,11 @@ fn test_max_results() {
};
assert_just_one_result_with_option("--max-results=1");
assert_just_one_result_with_option("-1");
// check that --max-results & -1 conflic with --exec
te.assert_failure(&["thing", "--max-results=0", "--exec=cat"]);
te.assert_failure(&["thing", "-1", "--exec=cat"]);
te.assert_failure(&["thing", "--max-results=1", "-1", "--exec=cat"]);
}
/// Filenames with non-utf8 paths are passed to the executed program unchanged