forked from StrafesNET/map-tool
write approximate code for uploading new asset
This commit is contained in:
parent
1cd77984d4
commit
980da5a6a7
23
src/main.rs
23
src/main.rs
@ -351,6 +351,7 @@ fn replace() -> BoxResult<()>{
|
|||||||
enum UploadAction {
|
enum UploadAction {
|
||||||
Upload(u64),
|
Upload(u64),
|
||||||
Skip,
|
Skip,
|
||||||
|
New,
|
||||||
}
|
}
|
||||||
struct ParseUploadActionErr;
|
struct ParseUploadActionErr;
|
||||||
impl std::str::FromStr for UploadAction {
|
impl std::str::FromStr for UploadAction {
|
||||||
@ -358,6 +359,8 @@ impl std::str::FromStr for UploadAction {
|
|||||||
fn from_str(s: &str) -> Result<Self, Self::Err>{
|
fn from_str(s: &str) -> Result<Self, Self::Err>{
|
||||||
if s=="skip\n"{
|
if s=="skip\n"{
|
||||||
Ok(Self::Skip)
|
Ok(Self::Skip)
|
||||||
|
}else if s=="new\n"{
|
||||||
|
Ok(Self::New)
|
||||||
}else{
|
}else{
|
||||||
if let Ok(asset_id)=s[..s.len()-1].parse::<u64>(){
|
if let Ok(asset_id)=s[..s.len()-1].parse::<u64>(){
|
||||||
Ok(Self::Upload(asset_id))
|
Ok(Self::Upload(asset_id))
|
||||||
@ -414,6 +417,26 @@ fn upload() -> BoxResult<()>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
UploadAction::Skip => continue,
|
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(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user