forked from StrafesNET/map-tool
rewrite clap usage
This commit is contained in:
parent
c1ddcdb0c5
commit
982b4aecac
57
src/main.rs
57
src/main.rs
@ -6,38 +6,59 @@ use anyhow::Result as AResult;
|
|||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
#[command(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(long)]
|
|
||||||
path:Option<PathBuf>,
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
DownloadTextures(PathBufList),
|
DownloadTextures(DownloadTexturesSubcommand),
|
||||||
ExtractTextures(PathBufList),
|
ExtractTextures(ExtractTexturesSubcommand),
|
||||||
ConvertTextures,
|
ConvertTextures(ConvertTexturesSubcommand),
|
||||||
VPKContents,
|
VPKContents(VPKContentsSubcommand),
|
||||||
BSPContents,
|
BSPContents(BSPContentsSubcommand),
|
||||||
DownloadMeshes(PathBufList),
|
DownloadMeshes(DownloadMeshesSubcommand),
|
||||||
WriteAttributes,
|
WriteAttributes(WriteAttributesSubcommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct PathBufList {
|
struct DownloadTexturesSubcommand {
|
||||||
paths:Vec<PathBuf>
|
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<()> {
|
fn main() -> AResult<()> {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths),
|
Commands::DownloadTextures(subcommand)=>download_textures(subcommand.roblox_files),
|
||||||
Commands::ExtractTextures(pathlist)=>extract_textures(vec![cli.path.unwrap()],pathlist.paths),
|
Commands::ExtractTextures(subcommand)=>extract_textures(vec![subcommand.bsp_file],subcommand.vpk_dir_files),
|
||||||
Commands::VPKContents=>vpk_contents(cli.path.unwrap()),
|
Commands::VPKContents(subcommand)=>vpk_contents(subcommand.input_file),
|
||||||
Commands::BSPContents=>bsp_contents(cli.path.unwrap()),
|
Commands::BSPContents(subcommand)=>bsp_contents(subcommand.input_file),
|
||||||
Commands::ConvertTextures=>convert_textures(),
|
Commands::ConvertTextures(_subcommand)=>convert_textures(),
|
||||||
Commands::DownloadMeshes(pathlist)=>download_meshes(pathlist.paths),
|
Commands::DownloadMeshes(subcommand)=>download_meshes(subcommand.roblox_files),
|
||||||
Commands::WriteAttributes=>write_attributes(),
|
Commands::WriteAttributes(_subcommand)=>write_attributes(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user