vpk contents + shorten arg

This commit is contained in:
Quaternions 2024-01-08 23:08:19 -08:00
parent 8b7f034f50
commit 9e30f5dca7

View File

@ -7,7 +7,7 @@ use anyhow::Result as AResult;
#[command(propagate_version = true)]
struct Cli {
#[arg(long)]
vpk_path:Option<std::path::PathBuf>,
vpk:Option<std::path::PathBuf>,
#[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),
@ -1096,3 +1098,11 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,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(())
}