Skip to content

Commit

Permalink
Load from packages by name
Browse files Browse the repository at this point in the history
  • Loading branch information
cohaereo committed Feb 18, 2024
1 parent c7dbe76 commit ac41172
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// Map hash to load. Ignores package argument(s)
#[arg(short, long)]
map: Option<String>,

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit ac41172

Please sign in to comment.