From ac4117209cd5331a4daa0a9074df2954a7e47e46 Mon Sep 17 00:00:00 2001 From: cohaereo Date: Sun, 18 Feb 2024 12:58:11 +0100 Subject: [PATCH] Load from packages by name --- CHANGELOG.md | 4 ++++ src/main.rs | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3a9dd8e..dd96a7c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ## Unreleased / Rolling Release +### Added + +- Added the ability to load maps from packages by name (eg. `throneworld` or `dungeon_prophecy`) through the `-p` argument by @cohaereo + ### Fixed - Fixed the GitHub URL for stable releases diff --git a/src/main.rs b/src/main.rs index 2b432426..078e23ec 100755 --- a/src/main.rs +++ b/src/main.rs @@ -144,7 +144,12 @@ struct Args { /// Package to use package: String, - /// Map hash to load. Ignores package argument + /// Package prefix to load maps from, ignores package argument. + /// For example: `throneworld`, `edz` + #[arg(short, long)] + package_name: Option, + + /// Map hash to load. Ignores package argument(s) #[arg(short, long)] map: Option, @@ -331,6 +336,18 @@ pub async fn main() -> anyhow::Result<()> { } vec![hash] + } else if let Some(package_name) = &args.package_name { + let filter = format!("w64_{package_name}_"); + package_manager() + .get_all_by_reference(u32::from_be(0x1E898080)) + .into_iter() + .filter(|(tag, _)| { + package_manager().package_paths[&tag.pkg_id()] + .to_lowercase() + .contains(&filter) + }) + .map(|(tag, _entry)| tag) + .collect_vec() } else { package .get_all_by_reference(u32::from_be(0x1E898080))