From 2a302904efb07006db67d02d10fdbb55b1361750 Mon Sep 17 00:00:00 2001 From: Brett Mayson Date: Thu, 24 Oct 2024 22:49:43 +0000 Subject: [PATCH] help shows the correct command --- libs/stringtable/src/analyze/lints/01_sorted.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/stringtable/src/analyze/lints/01_sorted.rs b/libs/stringtable/src/analyze/lints/01_sorted.rs index e9f1bdf8..09815f99 100644 --- a/libs/stringtable/src/analyze/lints/01_sorted.rs +++ b/libs/stringtable/src/analyze/lints/01_sorted.rs @@ -48,9 +48,10 @@ impl LintRunner for Runner { ) -> Codes { let mut unsorted = Vec::new(); let mut codes: Codes = Vec::new(); + let only_lang = matches!(config.option("only-lang"), Some(toml::Value::Boolean(true))); for (project, addon, existing) in target { let mut project = project.clone(); - if !matches!(config.option("only-lang"), Some(toml::Value::Boolean(true))) { + if !only_lang { project.sort(); } let mut writer = String::new(); @@ -65,12 +66,14 @@ impl LintRunner for Runner { for addon in unsorted { codes.push(Arc::new(CodeStringtableNotSorted::new( Unsorted::Addon(addon), + only_lang, config.severity(), ))); } } else { codes.push(Arc::new(CodeStringtableNotSorted::new( Unsorted::Addons(unsorted), + only_lang, config.severity(), ))); } @@ -86,6 +89,7 @@ pub enum Unsorted { #[allow(clippy::module_name_repetitions)] pub struct CodeStringtableNotSorted { unsorted: Unsorted, + only_lang: bool, severity: Severity, diagnostic: Option, } @@ -109,7 +113,11 @@ impl Code for CodeStringtableNotSorted { } fn help(&self) -> Option { - Some("Run `hemtt ln sort` to sort the stringtable".to_string()) + if self.only_lang { + Some("Run `hemtt ln sort --only-lang` to sort the stringtable".to_string()) + } else { + Some("Run `hemtt ln sort` to sort the stringtable".to_string()) + } } fn diagnostic(&self) -> Option { @@ -119,9 +127,10 @@ impl Code for CodeStringtableNotSorted { impl CodeStringtableNotSorted { #[must_use] - pub fn new(unsorted: Unsorted, severity: Severity) -> Self { + pub fn new(unsorted: Unsorted, only_lang: bool, severity: Severity) -> Self { Self { unsorted, + only_lang, severity, diagnostic: None, }