From 9db31c9191834faecf9f575cf5af87ac3b848245 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Tue, 27 Nov 2018 10:38:44 -0800 Subject: [PATCH] Stub out build command for generating rbxmx files --- server/src/bin.rs | 24 ++++++++++++++++++++++++ server/src/commands/build.rs | 13 +++++++++++++ server/src/commands/mod.rs | 4 +++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 server/src/commands/build.rs diff --git a/server/src/bin.rs b/server/src/bin.rs index d8783082..acef7ece 100644 --- a/server/src/bin.rs +++ b/server/src/bin.rs @@ -10,6 +10,8 @@ use std::{ env, }; +use librojo::commands; + fn make_path_absolute(value: &Path) -> PathBuf { if value.is_absolute() { PathBuf::from(value) @@ -40,6 +42,11 @@ fn main() { (@arg port: --port +takes_value "The port to listen on. Defaults to 8000.") ) + (@subcommand build => + (about: "Generates a .model.json, rbxm, or rbxmx model from the project.") + (@arg PROJECT: "Path to the project to serve. Defaults to the current directory.") + (@arg output: --output +takes_value +required "Where to output the result.") + ) ).get_matches(); match matches.subcommand() { @@ -60,6 +67,23 @@ fn main() { librojo::commands::serve(&project_path); }, + ("build", sub_matches) => { + let sub_matches = sub_matches.unwrap(); + + 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 output_file = make_path_absolute(Path::new(sub_matches.value_of("output").unwrap())); + + let options = commands::BuildOptions { + fuzzy_project_path, + output_file, + }; + + commands::build(&options); + }, _ => { error!("Please specify a subcommand!"); error!("Try 'rojo help' for information."); diff --git a/server/src/commands/build.rs b/server/src/commands/build.rs new file mode 100644 index 00000000..0c7d51eb --- /dev/null +++ b/server/src/commands/build.rs @@ -0,0 +1,13 @@ +use std::{ + path::PathBuf, +}; + +#[derive(Debug)] +pub struct BuildOptions { + pub fuzzy_project_path: PathBuf, + pub output_file: PathBuf, +} + +pub fn build(options: &BuildOptions) { + println!("build {:#?}", options); +} \ No newline at end of file diff --git a/server/src/commands/mod.rs b/server/src/commands/mod.rs index db228aa1..6f2bb133 100644 --- a/server/src/commands/mod.rs +++ b/server/src/commands/mod.rs @@ -1,5 +1,7 @@ mod serve; mod init; +mod build; pub use self::serve::*; -pub use self::init::*; \ No newline at end of file +pub use self::init::*; +pub use self::build::*; \ No newline at end of file