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)] #[command(propagate_version = true)]
struct Cli { struct Cli {
#[arg(long)] #[arg(long)]
vpk_path:Option<std::path::PathBuf>, vpk:Option<std::path::PathBuf>,
#[command(subcommand)] #[command(subcommand)]
command: Commands, command: Commands,
} }
@ -18,6 +18,7 @@ enum Commands {
DownloadTextures(PathBufList), DownloadTextures(PathBufList),
ExtractTextures(PathBufList), ExtractTextures(PathBufList),
ConvertTextures, ConvertTextures,
VPKContents,
DownloadMeshes(PathBufList), DownloadMeshes(PathBufList),
Extract(PathBufList), Extract(PathBufList),
WriteAttributes, WriteAttributes,
@ -43,7 +44,8 @@ fn main() -> AResult<()> {
match cli.command { match cli.command {
Commands::Download(map_list)=>download(map_list.maps), Commands::Download(map_list)=>download(map_list.maps),
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths), 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::ConvertTextures=>convert_textures(),
Commands::DownloadMeshes(pathlist)=>download_meshes(pathlist.paths), Commands::DownloadMeshes(pathlist)=>download_meshes(pathlist.paths),
Commands::Extract(pathlist)=>extract(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(()) 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(())
}