rewrite clap usage

This commit is contained in:
Quaternions 2024-03-08 10:23:36 -08:00
parent c1ddcdb0c5
commit 982b4aecac

View File

@ -6,38 +6,59 @@ use anyhow::Result as AResult;
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[arg(long)]
path:Option<PathBuf>,
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
DownloadTextures(PathBufList),
ExtractTextures(PathBufList),
ConvertTextures,
VPKContents,
BSPContents,
DownloadMeshes(PathBufList),
WriteAttributes,
DownloadTextures(DownloadTexturesSubcommand),
ExtractTextures(ExtractTexturesSubcommand),
ConvertTextures(ConvertTexturesSubcommand),
VPKContents(VPKContentsSubcommand),
BSPContents(BSPContentsSubcommand),
DownloadMeshes(DownloadMeshesSubcommand),
WriteAttributes(WriteAttributesSubcommand),
}
#[derive(Args)]
struct PathBufList {
paths:Vec<PathBuf>
struct DownloadTexturesSubcommand {
roblox_files:Vec<PathBuf>
}
#[derive(Args)]
struct ExtractTexturesSubcommand {
bsp_file:PathBuf,
vpk_dir_files:Vec<PathBuf>
}
#[derive(Args)]
struct ConvertTexturesSubcommand {
}
#[derive(Args)]
struct VPKContentsSubcommand {
input_file:PathBuf,
}
#[derive(Args)]
struct BSPContentsSubcommand {
input_file:PathBuf,
}
#[derive(Args)]
struct DownloadMeshesSubcommand {
roblox_files:Vec<PathBuf>
}
#[derive(Args)]
struct WriteAttributesSubcommand {
}
fn main() -> AResult<()> {
let cli = Cli::parse();
match cli.command {
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths),
Commands::ExtractTextures(pathlist)=>extract_textures(vec![cli.path.unwrap()],pathlist.paths),
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::WriteAttributes=>write_attributes(),
Commands::DownloadTextures(subcommand)=>download_textures(subcommand.roblox_files),
Commands::ExtractTextures(subcommand)=>extract_textures(vec![subcommand.bsp_file],subcommand.vpk_dir_files),
Commands::VPKContents(subcommand)=>vpk_contents(subcommand.input_file),
Commands::BSPContents(subcommand)=>bsp_contents(subcommand.input_file),
Commands::ConvertTextures(_subcommand)=>convert_textures(),
Commands::DownloadMeshes(subcommand)=>download_meshes(subcommand.roblox_files),
Commands::WriteAttributes(_subcommand)=>write_attributes(),
}
}