Lints and suggestions for the Nix programming language
at main 25 lines 673 B view raw
1use crate::{err::ExplainErr, utils}; 2 3pub fn explain(code: u32) -> Result<&'static str, ExplainErr> { 4 let lints = utils::lint_map(); 5 match code { 6 0 => Ok("syntax error"), 7 _ => lints 8 .values() 9 .flatten() 10 .find(|l| l.code() == code) 11 .map(|l| l.explanation()) 12 .ok_or(ExplainErr::LintNotFound(code)), 13 } 14} 15 16pub mod main { 17 18 use crate::{config::Explain as ExplainConfig, err::StatixErr}; 19 20 pub fn main(explain_config: &ExplainConfig) -> Result<(), StatixErr> { 21 let explanation = super::explain(explain_config.target)?; 22 println!("{explanation}"); 23 Ok(()) 24 } 25}