Skip to content

Commit

Permalink
Merge pull request #1394 from final-israel/make_max_results_one_confl…
Browse files Browse the repository at this point in the history
…ict_with_exec

Making `-1` conflict with `--exec` and making `max-results` override `-1`
  • Loading branch information
tmccombs committed Oct 5, 2023
2 parents 93cdb26 + dea9110 commit fc240f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
)]
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc240f7

Please sign in to comment.