diff --git a/src/main.rs b/src/main.rs index eb925da..d6a0d48 100644 --- a/src/main.rs +++ b/src/main.rs @@ -95,9 +95,14 @@ struct CreateAssetMediaSubcommand{ #[arg(long)] input_file:PathBuf, #[arg(long)] + asset_type:AssetType, + #[arg(long)] creator_user_id:u64, #[arg(long)] creator_group_id:Option, + /// Expected price limits how much robux can be spent to create the asset (defaults to 0) + #[arg(long)] + expected_price:Option, } #[derive(Args)] struct UpdateAssetMediaSubcommand{ @@ -270,6 +275,21 @@ impl Style{ } } } +#[derive(Clone,Copy,Debug,clap::ValueEnum)] +enum AssetType{ + Audio, + Decal, + Model, +} +impl AssetType{ + fn cloud(&self)->rbx_asset::cloud::AssetType{ + match self{ + AssetType::Audio=>rbx_asset::cloud::AssetType::Audio, + AssetType::Decal=>rbx_asset::cloud::AssetType::Decal, + AssetType::Model=>rbx_asset::cloud::AssetType::Model, + } + } +} #[tokio::main] async fn main()->AResult<()>{ @@ -335,8 +355,10 @@ async fn main()->AResult<()>{ creator_user_id:subcommand.creator_user_id, creator_group_id:subcommand.creator_group_id, input_file:subcommand.input_file, + asset_type:subcommand.asset_type.cloud(), model_name:subcommand.model_name, description:subcommand.description.unwrap_or_else(||String::with_capacity(0)), + expected_price:subcommand.expected_price, }).await, Commands::UploadAssetMedia(subcommand)=>upload_asset_media(UploadAssetMediaConfig{ api_key:api_key_from_args( @@ -443,18 +465,19 @@ async fn api_key_from_args(literal:Option,environment:Option,fil struct CreateAssetMediaConfig{ api_key:ApiKey, + asset_type:rbx_asset::cloud::AssetType, model_name:String, description:String, input_file:PathBuf, creator_user_id:u64, creator_group_id:Option, + expected_price:Option, } -///This is hardcoded to create models atm async fn create_asset_media(config:CreateAssetMediaConfig)->AResult<()>{ let resp=CloudContext::new(config.api_key) .create_asset(rbx_asset::cloud::CreateAssetRequest{ - assetType:rbx_asset::cloud::AssetType::Model, + assetType:config.asset_type, displayName:config.model_name, description:config.description, creationContext:rbx_asset::cloud::CreationContext{ @@ -462,7 +485,7 @@ async fn create_asset_media(config:CreateAssetMediaConfig)->AResult<()>{ userId:config.creator_user_id, groupId:config.creator_group_id.unwrap_or(0), }, - expectedPrice:0, + expectedPrice:config.expected_price.unwrap_or(0), } },tokio::fs::read(config.input_file).await?).await?; println!("CreateResponse={:?}",resp);