add bsp_contents and use --path instead of --vpk

This commit is contained in:
Quaternions 2024-01-10 16:47:11 -08:00
parent 48d3fca895
commit 8c0f46007f

View File

@ -7,7 +7,7 @@ use anyhow::Result as AResult;
#[command(propagate_version = true)]
struct Cli {
#[arg(long)]
vpk:Option<std::path::PathBuf>,
path:Option<std::path::PathBuf>,
#[command(subcommand)]
command: Commands,
}
@ -19,6 +19,7 @@ enum Commands {
ExtractTextures(PathBufList),
ConvertTextures,
VPKContents,
BSPContents,
DownloadMeshes(PathBufList),
Extract(PathBufList),
WriteAttributes,
@ -44,8 +45,9 @@ 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.unwrap()),
Commands::VPKContents=>vpk_contents(cli.vpk.unwrap()),
Commands::ExtractTextures(pathlist)=>extract_textures(pathlist.paths,cli.path.unwrap()),
Commands::VPKContents=>vpk_contents(cli.path.unwrap()),
Commands::BSPContents=>bsp_contents(cli.path.unwrap()),
Commands::ConvertTextures=>convert_textures(),
Commands::DownloadMeshes(pathlist)=>download_meshes(pathlist.paths),
Commands::Extract(pathlist)=>extract(pathlist.paths),
@ -1251,3 +1253,11 @@ fn vpk_contents(vpk_path:std::path::PathBuf)->AResult<()>{
}
Ok(())
}
fn bsp_contents(path:std::path::PathBuf)->AResult<()>{
let bsp=vbsp::Bsp::read(std::fs::read(path)?.as_ref())?;
for file_name in bsp.pack.into_zip().into_inner().unwrap().file_names(){
println!("file_name={:?}",file_name);
}
Ok(())
}