summaryrefslogtreecommitdiffstats
path: root/src/args.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/args.rs b/src/args.rs
index 7aed9144..623a230c 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -615,7 +615,10 @@ impl ArgMatches {
if let Some(limit) = self.dfa_size_limit()? {
builder.dfa_size_limit(limit);
}
- Ok(builder.build(&patterns.join("|"))?)
+ match builder.build(&patterns.join("|")) {
+ Ok(m) => Ok(m),
+ Err(err) => Err(From::from(suggest_multiline(err.to_string()))),
+ }
}
/// Build a matcher using PCRE2.
@@ -1546,6 +1549,17 @@ and look-around.", msg)
}
}
+fn suggest_multiline(msg: String) -> String {
+ if msg.contains("the literal") && msg.contains("not allowed") {
+ format!("{}
+
+Consider enabling multiline mode with the --multiline flag (or -U for short).
+When multiline mode is enabled, new line characters can be matched.", msg)
+ } else {
+ msg
+ }
+}
+
/// Convert the result of parsing a human readable file size to a `usize`,
/// failing if the type does not fit.
fn u64_to_usize(