From 9e30f5dca73310f36d415f13ebe6463c884197c8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 8 Jan 2024 23:08:19 -0800 Subject: [PATCH] vpk contents + shorten arg --- src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index fce857e..b316846 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use anyhow::Result as AResult; #[command(propagate_version = true)] struct Cli { #[arg(long)] - vpk_path:Option, + vpk:Option, #[command(subcommand)] command: Commands, } @@ -18,6 +18,7 @@ enum Commands { DownloadTextures(PathBufList), ExtractTextures(PathBufList), ConvertTextures, + VPKContents, DownloadMeshes(PathBufList), Extract(PathBufList), WriteAttributes, @@ -43,7 +44,8 @@ fn main() -> AResult<()> { match cli.command { Commands::Download(map_list)=>download(map_list.maps), Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths), - Commands::ExtractTextures(pathlist)=>extract_textures(pathlist.paths,cli.vpk_path.unwrap()), + Commands::ExtractTextures(pathlist)=>extract_textures(pathlist.paths,cli.vpk.unwrap()), + Commands::VPKContents=>vpk_contents(cli.vpk.unwrap()), Commands::ConvertTextures=>convert_textures(), Commands::DownloadMeshes(pathlist)=>download_meshes(pathlist.paths), Commands::Extract(pathlist)=>extract(pathlist.paths), @@ -1095,4 +1097,12 @@ fn extract_textures(paths:Vec,vpk_path:std::path::PathBuf)-> } } Ok(()) +} + +fn vpk_contents(vpk_path:std::path::PathBuf)->AResult<()>{ + let vpk_index=vpk::VPK::read(&vpk_path)?; + for (label,entry) in vpk_index.tree.into_iter(){ + println!("vpk label={} entry={:?}",label,entry); + } + Ok(()) } \ No newline at end of file