aboutsummaryrefslogtreecommitdiff
path: root/bin/src/explain.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-31 09:05:26 +0000
committerAkshay <[email protected]>2021-10-31 16:05:15 +0000
commite8c955da4cbb042e6f9b89307d143f5bfa6779fa (patch)
tree0ae4ec11fd3dc0f8b69bc0f32c08858ef23a9485 /bin/src/explain.rs
parent246c69f8cfc74cf4c56fdaceaeb0562ed1f3dad5 (diff)
add `explain` subcommand and explanations to all lints
Diffstat (limited to 'bin/src/explain.rs')
-rw-r--r--bin/src/explain.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/src/explain.rs b/bin/src/explain.rs
new file mode 100644
index 0000000..6aefa7e
--- /dev/null
+++ b/bin/src/explain.rs
@@ -0,0 +1,15 @@
1use crate::err::ExplainErr;
2
3use lib::LINTS;
4
5pub fn explain(code: u32) -> Result<&'static str, ExplainErr> {
6 match code {
7 0 => Ok("syntax error"),
8 _ => LINTS
9 .values()
10 .flatten()
11 .find(|l| l.code() == code)
12 .map(|l| l.explanation())
13 .ok_or(ExplainErr::LintNotFound(code)),
14 }
15}