Implement build command, shuffle around some internals to make it easier

This commit is contained in:
Lucien Greathouse
2018-11-27 14:07:00 -08:00
parent 7c585fcbce
commit 8aee5c769f
5 changed files with 67 additions and 26 deletions

View File

@@ -1,5 +1,15 @@
use std::{
path::PathBuf,
fs::File,
process,
};
use rbxmx;
use crate::{
rbx_session::construct_oneoff_tree,
project::Project,
imfs::Imfs,
};
#[derive(Debug)]
@@ -9,5 +19,27 @@ pub struct BuildOptions {
}
pub fn build(options: &BuildOptions) {
println!("build {:#?}", options);
info!("Looking for project at {}", options.fuzzy_project_path.display());
let project = match Project::load_fuzzy(&options.fuzzy_project_path) {
Ok(project) => project,
Err(error) => {
error!("{}", error);
process::exit(1);
},
};
info!("Found project at {}", project.file_location.display());
info!("Using project {:#?}", project);
let imfs = Imfs::new(&project)
.expect("Could not create in-memory filesystem");
let tree = construct_oneoff_tree(&project, &imfs);
let root_id = tree.get_root_id();
let mut file = File::create(&options.output_file)
.expect("Could not open output file for write");
rbxmx::encode(&tree, &[root_id], &mut file);
}