From 980da5a6a788bc8e6f0b8c06c32085a6400ae508 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 14 Sep 2023 16:18:33 -0700 Subject: [PATCH] write approximate code for uploading new asset --- src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4b1d116..035d2d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -351,6 +351,7 @@ fn replace() -> BoxResult<()>{ enum UploadAction { Upload(u64), Skip, + New, } struct ParseUploadActionErr; impl std::str::FromStr for UploadAction { @@ -358,6 +359,8 @@ impl std::str::FromStr for UploadAction { fn from_str(s: &str) -> Result{ if s=="skip\n"{ Ok(Self::Skip) + }else if s=="new\n"{ + Ok(Self::New) }else{ if let Ok(asset_id)=s[..s.len()-1].parse::(){ Ok(Self::Upload(asset_id)) @@ -414,6 +417,26 @@ fn upload() -> BoxResult<()>{ } } UploadAction::Skip => continue, + UploadAction::New => { + let output=std::process::Command::new("../rbxcompiler-linux-amd64") + .arg("--compile=false") + .arg("--group=6980477") + .arg("--new-asset=true") + .arg(format!("--input={}",file_thing.path().into_os_string().into_string().unwrap())) + .output()?; + match output.status.code() { + Some(0)=>{ + //print output + println!("{}", std::str::from_utf8(output.stdout.as_slice())?); + //move file + let mut dest=std::path::PathBuf::from("maps/uploaded"); + dest.push(file_thing.file_name()); + std::fs::rename(file_thing.path(), dest)?; + } + Some(code)=>println!("upload failed! code={}",code), + None => println!("no status code!"), + } + } } } Ok(())