use std::{io::Read,path::PathBuf}; use clap::{Args,Parser,Subcommand}; use anyhow::Result as AResult; use futures::StreamExt; use rbx_asset::cloud::{ApiKey,CloudContext}; use rbx_asset::cookie::{Cookie,CookieContext,AssetVersion,InventoryItem}; type AssetID=u64; type AssetIDFileMap=Vec<(AssetID,PathBuf)>; const CONCURRENT_DECODE:usize=8; const CONCURRENT_REQUESTS:usize=32; #[derive(Parser)] #[command(author,version,about,long_about=None)] #[command(propagate_version = true)] struct Cli{ #[command(subcommand)] command:Commands, } #[derive(Subcommand)] enum Commands{ DownloadHistory(DownloadHistorySubcommand), Download(DownloadSubcommand), DownloadDecompile(DownloadDecompileSubcommand), DownloadGroupInventoryJson(DownloadGroupInventoryJsonSubcommand), CreateAsset(CreateAssetSubcommand), UploadAsset(UpdateAssetSubcommand), UploadPlace(UpdatePlaceSubcommand), Compile(CompileSubcommand), CompileUploadAsset(CompileUploadAssetSubcommand), CompileUploadPlace(CompileUploadPlaceSubcommand), Decompile(DecompileSubcommand), DecompileHistoryIntoGit(DecompileHistoryIntoGitSubcommand), DownloadAndDecompileHistoryIntoGit(DownloadAndDecompileHistoryIntoGitSubcommand), } #[derive(Args)] struct DownloadHistorySubcommand{ #[arg(long)] asset_id:AssetID, #[arg(long,group="cookie",required=true)] cookie_literal:Option, #[arg(long,group="cookie",required=true)] cookie_envvar:Option, #[arg(long,group="cookie",required=true)] cookie_file:Option, #[arg(long)] output_folder:Option, #[arg(long)] continue_from_versions:Option, #[arg(long)] start_version:Option, #[arg(long)] end_version:Option, } #[derive(Args)] struct DownloadSubcommand{ #[arg(long,group="api_key",required=true)] api_key_literal:Option, #[arg(long,group="api_key",required=true)] api_key_envvar:Option, #[arg(long,group="api_key",required=true)] api_key_file:Option, #[arg(long)] output_folder:Option, #[arg(required=true)] asset_ids:Vec, } #[derive(Args)] struct DownloadGroupInventoryJsonSubcommand{ #[arg(long,group="cookie",required=true)] cookie_literal:Option, #[arg(long,group="cookie",required=true)] cookie_envvar:Option, #[arg(long,group="cookie",required=true)] cookie_file:Option, #[arg(long)] output_folder:Option, #[arg(long)] group:u64, } #[derive(Args)] struct CreateAssetSubcommand{ #[arg(long,group="api_key",required=true)] api_key_literal:Option, #[arg(long,group="api_key",required=true)] api_key_envvar:Option, #[arg(long,group="api_key",required=true)] api_key_file:Option, #[arg(long)] model_name:String, #[arg(long)] description:Option, #[arg(long)] input_file:PathBuf, #[arg(long)] creator_user_id:u64, #[arg(long)] creator_group_id:Option, } #[derive(Args)] struct UpdateAssetSubcommand{ #[arg(long)] asset_id:AssetID, #[arg(long,group="api_key",required=true)] api_key_literal:Option, #[arg(long,group="api_key",required=true)] api_key_envvar:Option, #[arg(long,group="api_key",required=true)] api_key_file:Option, #[arg(long)] input_file:PathBuf, } #[derive(Args)] struct UpdatePlaceSubcommand{ #[arg(long)] place_id:u64, #[arg(long)] universe_id:u64, #[arg(long,group="api_key",required=true)] api_key_literal:Option, #[arg(long,group="api_key",required=true)] api_key_envvar:Option, #[arg(long,group="api_key",required=true)] api_key_file:Option, #[arg(long)] input_file:PathBuf, } #[derive(Args)] struct CompileSubcommand{ #[arg(long)] input_folder:Option, #[arg(long)] output_file:PathBuf, #[arg(long)] style:Option