Skip to content

Commit

Permalink
help shows the correct command
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 24, 2024
1 parent fef138b commit 2a30290
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions libs/stringtable/src/analyze/lints/01_sorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ impl LintRunner<SqfLintData> 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();
Expand All @@ -65,12 +66,14 @@ impl LintRunner<SqfLintData> 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(),
)));
}
Expand All @@ -86,6 +89,7 @@ pub enum Unsorted {
#[allow(clippy::module_name_repetitions)]
pub struct CodeStringtableNotSorted {
unsorted: Unsorted,
only_lang: bool,
severity: Severity,
diagnostic: Option<Diagnostic>,
}
Expand All @@ -109,7 +113,11 @@ impl Code for CodeStringtableNotSorted {
}

fn help(&self) -> Option<String> {
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<Diagnostic> {
Expand All @@ -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,
}
Expand Down

0 comments on commit 2a30290

Please sign in to comment.