From dea9110b907d2db578c8519ccfe6308800c7c56b Mon Sep 17 00:00:00 2001 From: Eden Mikitas Date: Thu, 5 Oct 2023 15:10:37 +0300 Subject: [PATCH] Making `-1` conflict with `--exec` and making `max-results` override `-1` --- src/cli.rs | 3 ++- tests/tests.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index a60260e..9947267 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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 )] diff --git a/tests/tests.rs b/tests/tests.rs index 5330f40..daad76f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -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