From 22ed69e857e5934c86cc9712bb9a6eac742fc969 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 12 Apr 2020 23:44:48 +0800 Subject: [PATCH] Add test for suboptimal flag suggestion Fix #1073 --- tests/opts.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/opts.rs b/tests/opts.rs index ca693262..a2c79058 100644 --- a/tests/opts.rs +++ b/tests/opts.rs @@ -13,6 +13,17 @@ USAGE: For more information try --help"; +#[cfg(feature = "suggestions")] +static DYM_ISSUE_1073: &str = + "error: Found argument '--files-without-matches' which wasn't expected, or isn't valid in this context +\tDid you mean --files-without-match? +If you tried to supply `--files-without-matches` as a PATTERN use `-- --files-without-matches` + +USAGE: + ripgrep-616 --files-without-match + +For more information try --help"; + #[test] fn require_equals_fail() { let res = App::new("prog") @@ -454,3 +465,17 @@ fn issue_1105_empty_value_short_explicit_no_space() { let m = r.unwrap(); assert_eq!(m.value_of("option"), Some("")); } + +#[test] +#[cfg(feature = "suggestions")] +fn issue_1073_suboptimal_flag_suggestion() { + let app = App::new("ripgrep-616") + .arg(Arg::with_name("files-with-matches").long("files-with-matches")) + .arg(Arg::with_name("files-without-match").long("files-without-match")); + assert!(utils::compare_output( + app, + "ripgrep-616 --files-without-matches", + DYM_ISSUE_1073, + true + )); +}