Compare commits

...

2 Commits

Author SHA1 Message Date
8e589f7f0f download asset list 2024-01-16 21:50:35 -08:00
cbb5805d54 fix download path 2024-01-14 18:43:03 -08:00

@ -63,7 +63,7 @@ struct Cli{
#[derive(Subcommand)]
enum Commands{
DownloadHistory,
Download,
Download(AssetIDList),
Upload,
Compile,
Decompile,
@ -78,6 +78,11 @@ enum DecompileStyle{
RoxRojo,
}
#[derive(Args)]
struct AssetIDList{
asset_ids:Vec<AssetID>
}
#[derive(Args)]
struct PathBufList{
paths:Vec<std::path::PathBuf>
@ -149,7 +154,14 @@ async fn main()->AResult<()>{
cookie:cookie.unwrap(),
asset_id:cli.asset_id.unwrap(),
}).await,
Commands::Download=>download_list(cookie.unwrap(),vec![(cli.asset_id.unwrap(),cli.output.unwrap())]).await,
Commands::Download(asset_id_list)=>download_list(
cookie.unwrap(),
asset_id_list.asset_ids.into_iter().map(|asset_id|{
let mut path=cli.output.clone().unwrap();
path.push(asset_id.to_string());
(asset_id,path)
}).collect()
).await,
Commands::Upload=>upload_list(cookie.unwrap(),cli.group,vec![(cli.asset_id.unwrap(),cli.output.unwrap())]).await,
Commands::Compile=>compile(cli.input.unwrap(),cli.output.unwrap()),
Commands::Decompile=>decompile(DecompileConfig{
@ -445,7 +457,8 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{
let client=client.clone();
let cookie=cookie.clone();
let asset_id_str=asset_id_str.clone();
let output_folder=output_folder.clone();
let mut path=output_folder.clone();
path.push(format!("{}_v{}.rbxl",config.asset_id,version_number));
join_set.spawn(async move{
let resp=download_asset_version(&client,cookie.as_str(),asset_id_str.as_str(),version_number.to_string().as_str()).await?;
let contents=match maybe_gzip_decode(std::io::Cursor::new(resp.bytes().await?))?{
@ -453,9 +466,6 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{
ReaderType::Raw(readable)=>read_readable(readable)?,
};
let mut path=output_folder.clone();
path.set_file_name(format!("{}_v{}.rbxl",config.asset_id,version_number));
tokio::fs::write(path,contents).await?;
Ok::<_,anyhow::Error>(())