diff --git a/src/cli.rs b/src/cli.rs index dd8ddf17..50bf9926 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -46,6 +46,8 @@ pub enum Subcommand { Stats, /// Find duplicate manifest entries. Duplicates, + /// List games with irregular paths. + Irregular, } pub fn parse() -> Cli { @@ -158,6 +160,13 @@ pub async fn run( } } } + Subcommand::Irregular => { + for (game, info) in &wiki_cache.0 { + if info.any_irregular_paths(game.to_string()) { + println!("{}", game); + } + } + } } Ok(()) diff --git a/src/wiki.rs b/src/wiki.rs index c199b278..94397b79 100644 --- a/src/wiki.rs +++ b/src/wiki.rs @@ -428,6 +428,13 @@ impl WikiCacheEntry { } pub fn parse_paths(&self, article: String) -> Vec { + self.parse_all_paths(article) + .into_iter() + .filter(|x| x.usable()) + .collect() + } + + fn parse_all_paths(&self, article: String) -> Vec { let mut out = vec![]; for raw in &self.templates { @@ -448,9 +455,7 @@ impl WikiCacheEntry { .with_platform(&platform) .with_tags(is_save, is_config) .normalize(); - if info.usable() { - out.push(info); - } + out.push(info); } } } @@ -458,6 +463,15 @@ impl WikiCacheEntry { out } + + pub fn any_irregular_paths(&self, article: String) -> bool { + for path in self.parse_all_paths(article) { + if path.irregular() { + return true; + } + } + false + } } #[derive(Debug, Clone, Copy)] @@ -712,7 +726,7 @@ pub fn flatten_path(attribute: &Attribute) -> WikiPath { out.incorporate_raw(flat); } } - "note" => { + "note" | "cn" => { // Ignored. } _ => {