diff --git a/Cargo.lock b/Cargo.lock index 3eb67fe..fe6a97a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "rbx_asset" -version = "0.1.0" +version = "0.2.0" dependencies = [ "chrono", "flate2", diff --git a/rbx_asset/Cargo.toml b/rbx_asset/Cargo.toml index 93b59e4..5164554 100644 --- a/rbx_asset/Cargo.toml +++ b/rbx_asset/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rbx_asset" -version = "0.1.0" +version = "0.2.0" edition = "2021" publish = ["strafesnet"] diff --git a/rbx_asset/src/context.rs b/rbx_asset/src/context.rs index 3ab9d5b..b52b03b 100644 --- a/rbx_asset/src/context.rs +++ b/rbx_asset/src/context.rs @@ -103,17 +103,17 @@ pub struct GetAssetRequest{ pub version:Option, } #[derive(Debug)] -pub enum DownloadError{ +pub enum GetError{ ParseError(url::ParseError), Reqwest(reqwest::Error), IO(std::io::Error) } -impl std::fmt::Display for DownloadError{ +impl std::fmt::Display for GetError{ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f,"{self:?}") } } -impl std::error::Error for DownloadError{} +impl std::error::Error for GetError{} pub struct AssetVersionsRequest{ pub asset_id:u64, @@ -267,8 +267,8 @@ impl RobloxContext{ Ok(resp.json::().await.map_err(UpdateError::Reqwest)?) } - pub async fn get_asset(&self,config:GetAssetRequest)->Result,DownloadError>{ - let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(DownloadError::ParseError)?; + pub async fn get_asset(&self,config:GetAssetRequest)->Result,GetError>{ + let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?; //url borrow scope { let mut query=url.query_pairs_mut();//borrow here @@ -277,15 +277,15 @@ impl RobloxContext{ query.append_pair("version",version.to_string().as_str()); } } - let resp=self.get(url).await.map_err(DownloadError::Reqwest)?; + let resp=self.get(url).await.map_err(GetError::Reqwest)?; - let body=resp.bytes().await.map_err(DownloadError::Reqwest)?; + let body=resp.bytes().await.map_err(GetError::Reqwest)?; match maybe_gzip_decode(&mut std::io::Cursor::new(body)){ Ok(ReaderType::GZip(readable))=>read_readable(readable), Ok(ReaderType::Raw(readable))=>read_readable(readable), Err(e)=>Err(e), - }.map_err(DownloadError::IO) + }.map_err(GetError::IO) } pub async fn get_asset_versions(&self,config:AssetVersionsRequest)->Result{ let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}/versions",config.asset_id); diff --git a/src/main.rs b/src/main.rs index 589e994..775846a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,8 +25,10 @@ enum Commands{ DownloadGroupInventoryJson(DownloadGroupInventoryJsonSubcommand), CreateAsset(CreateAssetSubcommand), UploadAsset(UpdateAssetSubcommand), + UploadPlace(UpdatePlaceSubcommand), Compile(CompileSubcommand), - CompileUpload(CompileUploadSubcommand), + CompileUploadAsset(CompileUploadAssetSubcommand), + CompileUploadPlace(CompileUploadPlaceSubcommand), Decompile(DecompileSubcommand), DecompileHistoryIntoGit(DecompileHistoryIntoGitSubcommand), DownloadAndDecompileHistoryIntoGit(DownloadAndDecompileHistoryIntoGitSubcommand), @@ -36,10 +38,12 @@ enum Commands{ struct DownloadHistorySubcommand{ #[arg(long)] asset_id:AssetID, - #[arg(long)] - cookie_type:CookieType, - #[arg(long)] - cookie:String, + #[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(long)] @@ -51,10 +55,12 @@ struct DownloadHistorySubcommand{ } #[derive(Args)] struct DownloadSubcommand{ - #[arg(long)] - cookie_type:CookieType, - #[arg(long)] - cookie:String, + #[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)] @@ -62,10 +68,12 @@ struct DownloadSubcommand{ } #[derive(Args)] struct DownloadGroupInventoryJsonSubcommand{ - #[arg(long)] - cookie_type:CookieType, - #[arg(long)] - cookie:String, + #[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(long)] @@ -73,10 +81,12 @@ struct DownloadGroupInventoryJsonSubcommand{ } #[derive(Args)] struct CreateAssetSubcommand{ - #[arg(long)] - cookie_type:CookieType, - #[arg(long)] - cookie:String, + #[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)] @@ -85,19 +95,32 @@ struct CreateAssetSubcommand{ input_file:PathBuf, #[arg(long)] group:Option, - #[arg(long)] - free_model:Option, - #[arg(long)] - allow_comments: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)] - cookie_type:CookieType, + input_file:PathBuf, +} +#[derive(Args)] +struct UpdatePlaceSubcommand{ #[arg(long)] - cookie:String, + 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, } @@ -113,17 +136,38 @@ struct CompileSubcommand{ template:Option, } #[derive(Args)] -struct CompileUploadSubcommand{ +struct CompileUploadAssetSubcommand{ #[arg(long)] asset_id:AssetID, - #[arg(long)] - cookie_type:CookieType, - #[arg(long)] - cookie:String, + #[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, #[arg(long)] - group:Option, + input_folder:Option, + #[arg(long)] + style:Option