Add 'upload' command to publish places to Roblox for you

This commit is contained in:
Lucien Greathouse
2019-01-07 14:01:53 -08:00
parent 1992ce1cfb
commit 99ea374fc5
3 changed files with 133 additions and 1 deletions

View File

@@ -45,6 +45,13 @@ fn main() {
(@arg PROJECT: "Path to the project to serve. Defaults to the current directory.")
(@arg output: --output +takes_value +required "Where to output the result.")
)
(@subcommand upload =>
(about: "Generates a place file out of the project and uploads it to Roblox.")
(@arg PROJECT: "Path to the project to upload. Defaults to the current directory.")
(@arg cookie: --cookie +takes_value +required "Security cookie to authenticate with.")
(@arg place_id: --place_id +takes_value +required "Place ID to upload to.")
)
);
// `get_matches` consumes self for some reason.
@@ -109,6 +116,40 @@ fn main() {
},
}
},
("upload", Some(sub_matches)) => {
let fuzzy_project_path = match sub_matches.value_of("PROJECT") {
Some(v) => make_path_absolute(Path::new(v)),
None => std::env::current_dir().unwrap(),
};
let security_cookie = sub_matches.value_of("cookie").unwrap();
let place_id: u64 = {
let arg = sub_matches.value_of("place_id").unwrap();
match arg.parse() {
Ok(v) => v,
Err(_) => {
error!("Invalid place ID {}", arg);
process::exit(1);
},
}
};
let options = commands::UploadOptions {
fuzzy_project_path,
security_cookie: security_cookie.to_string(),
place_id,
};
match commands::upload(&options) {
Ok(_) => {},
Err(e) => {
error!("{}", e);
process::exit(1);
},
}
},
_ => {
app.print_help().expect("Could not print help text to stdout!");
},