diff --git a/src/main.rs b/src/main.rs index 8f08bc0..45a67a9 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:Option, + path:Option, #[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), @@ -1250,4 +1252,12 @@ fn vpk_contents(vpk_path:std::path::PathBuf)->AResult<()>{ println!("vpk label={} entry={:?}",label,entry); } 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(()) } \ No newline at end of file