rm: unnecessary MessageText struct

This commit is contained in:
itiB
2020-11-05 04:19:44 +09:00
parent b42ab6a0d5
commit e8c0ec44f8
3 changed files with 1 additions and 33 deletions

View File

@@ -50,17 +50,6 @@ impl Message {
} }
} }
/// メッセージテキストを言語設定に合わせて返す
/// println!("{}", <MessageText>) とすると今の言語設定で出力される
impl fmt::Display for MessageText {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match get_lang() {
Lang::Ja => write!(f, "{}", self.ja),
Lang::En => write!(f, "{}", self.en),
}
}
}
/// Argsから言語情報を読み取り Lang を返す /// Argsから言語情報を読み取り Lang を返す
pub fn get_lang() -> Lang { pub fn get_lang() -> Lang {
let lang: String = singleton().args.value_of("lang").unwrap_or("").to_string(); let lang: String = singleton().args.value_of("lang").unwrap_or("").to_string();

View File

@@ -5,7 +5,6 @@ use quick_xml::de::DeError;
use std::{fs, path::PathBuf, process}; use std::{fs, path::PathBuf, process};
use yamato_event_analyzer::detections::configs; use yamato_event_analyzer::detections::configs;
use yamato_event_analyzer::detections::detection; use yamato_event_analyzer::detections::detection;
use yamato_event_analyzer::detections::print::MESSAGES;
use yamato_event_analyzer::omikuji::Omikuji; use yamato_event_analyzer::omikuji::Omikuji;
use yamato_event_analyzer::toml; use yamato_event_analyzer::toml;
@@ -14,20 +13,6 @@ fn main() -> Result<(), DeError> {
let mut toml = toml::ParseToml::new(); let mut toml = toml::ParseToml::new();
&toml.read_dir("rules".to_string()); &toml.read_dir("rules".to_string());
for rule in toml.rules {
match rule {
Ok(_rule) => {
let mut message = MESSAGES.lock().unwrap();
if let Some(messages) = _rule.rule.messages {
for (key, texts) in messages {
message.insert(key, texts);
}
}
}
Err(_) => (),
}
}
let filepath: String = configs::singleton() let filepath: String = configs::singleton()
.args .args
.value_of("filepath") .value_of("filepath")

View File

@@ -5,13 +5,7 @@ use serde::Deserialize;
pub struct Rule { pub struct Rule {
pub severity: Option<String>, pub severity: Option<String>,
pub name: Option<String>, pub name: Option<String>,
pub messages: Option<Vec<(String, MessageText)>>, pub messages: Option<Vec<(String, String)>>,
}
#[derive(Debug, Deserialize)]
pub struct MessageText {
pub ja: String,
pub en: String,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]