Add command to list games with irregular paths
This commit is contained in:
parent
23e5f483d4
commit
e5a2b9dce9
2 changed files with 27 additions and 4 deletions
|
@ -46,6 +46,8 @@ pub enum Subcommand {
|
||||||
Stats,
|
Stats,
|
||||||
/// Find duplicate manifest entries.
|
/// Find duplicate manifest entries.
|
||||||
Duplicates,
|
Duplicates,
|
||||||
|
/// List games with irregular paths.
|
||||||
|
Irregular,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse() -> Cli {
|
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(())
|
Ok(())
|
||||||
|
|
22
src/wiki.rs
22
src/wiki.rs
|
@ -428,6 +428,13 @@ impl WikiCacheEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_paths(&self, article: String) -> Vec<WikiPath> {
|
pub fn parse_paths(&self, article: String) -> Vec<WikiPath> {
|
||||||
|
self.parse_all_paths(article)
|
||||||
|
.into_iter()
|
||||||
|
.filter(|x| x.usable())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_all_paths(&self, article: String) -> Vec<WikiPath> {
|
||||||
let mut out = vec![];
|
let mut out = vec![];
|
||||||
|
|
||||||
for raw in &self.templates {
|
for raw in &self.templates {
|
||||||
|
@ -448,9 +455,7 @@ impl WikiCacheEntry {
|
||||||
.with_platform(&platform)
|
.with_platform(&platform)
|
||||||
.with_tags(is_save, is_config)
|
.with_tags(is_save, is_config)
|
||||||
.normalize();
|
.normalize();
|
||||||
if info.usable() {
|
out.push(info);
|
||||||
out.push(info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,6 +463,15 @@ impl WikiCacheEntry {
|
||||||
|
|
||||||
out
|
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)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
@ -712,7 +726,7 @@ pub fn flatten_path(attribute: &Attribute) -> WikiPath {
|
||||||
out.incorporate_raw(flat);
|
out.incorporate_raw(flat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"note" => {
|
"note" | "cn" => {
|
||||||
// Ignored.
|
// Ignored.
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
Reference in a new issue