mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
Clean up bin, print better help text
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
#[macro_use] extern crate clap;
|
#[macro_use] extern crate clap;
|
||||||
#[macro_use] extern crate log;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process,
|
|
||||||
env,
|
env,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +21,7 @@ fn main() {
|
|||||||
.default_format_timestamp(false)
|
.default_format_timestamp(false)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let matches = clap_app!(rojo =>
|
let mut app = clap_app!(Rojo =>
|
||||||
(version: env!("CARGO_PKG_VERSION"))
|
(version: env!("CARGO_PKG_VERSION"))
|
||||||
(author: env!("CARGO_PKG_AUTHORS"))
|
(author: env!("CARGO_PKG_AUTHORS"))
|
||||||
(about: env!("CARGO_PKG_DESCRIPTION"))
|
(about: env!("CARGO_PKG_DESCRIPTION"))
|
||||||
@@ -40,23 +38,23 @@ fn main() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
(@subcommand build =>
|
(@subcommand build =>
|
||||||
(about: "Generates a .model.json, rbxm, or rbxmx model from the project.")
|
(about: "Generates an rbxmx model file from the project.")
|
||||||
(@arg PROJECT: "Path to the project to serve. Defaults to the current directory.")
|
(@arg PROJECT: "Path to the project to serve. Defaults to the current directory.")
|
||||||
(@arg output: --output +takes_value +required "Where to output the result.")
|
(@arg output: --output +takes_value +required "Where to output the result.")
|
||||||
)
|
)
|
||||||
).get_matches();
|
);
|
||||||
|
|
||||||
|
// `get_matches` consumes self for some reason.
|
||||||
|
let matches = app.clone().get_matches();
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
("init", sub_matches) => {
|
("init", Some(sub_matches)) => {
|
||||||
let sub_matches = sub_matches.unwrap();
|
|
||||||
let project_path = Path::new(sub_matches.value_of("PATH").unwrap_or("."));
|
let project_path = Path::new(sub_matches.value_of("PATH").unwrap_or("."));
|
||||||
let full_path = make_path_absolute(project_path);
|
let full_path = make_path_absolute(project_path);
|
||||||
|
|
||||||
librojo::commands::init(&full_path);
|
librojo::commands::init(&full_path);
|
||||||
},
|
},
|
||||||
("serve", sub_matches) => {
|
("serve", Some(sub_matches)) => {
|
||||||
let sub_matches = sub_matches.unwrap();
|
|
||||||
|
|
||||||
let project_path = match sub_matches.value_of("PROJECT") {
|
let project_path = match sub_matches.value_of("PROJECT") {
|
||||||
Some(v) => make_path_absolute(Path::new(v)),
|
Some(v) => make_path_absolute(Path::new(v)),
|
||||||
None => std::env::current_dir().unwrap(),
|
None => std::env::current_dir().unwrap(),
|
||||||
@@ -64,9 +62,7 @@ fn main() {
|
|||||||
|
|
||||||
librojo::commands::serve(&project_path);
|
librojo::commands::serve(&project_path);
|
||||||
},
|
},
|
||||||
("build", sub_matches) => {
|
("build", Some(sub_matches)) => {
|
||||||
let sub_matches = sub_matches.unwrap();
|
|
||||||
|
|
||||||
let fuzzy_project_path = match sub_matches.value_of("PROJECT") {
|
let fuzzy_project_path = match sub_matches.value_of("PROJECT") {
|
||||||
Some(v) => make_path_absolute(Path::new(v)),
|
Some(v) => make_path_absolute(Path::new(v)),
|
||||||
None => std::env::current_dir().unwrap(),
|
None => std::env::current_dir().unwrap(),
|
||||||
@@ -82,9 +78,7 @@ fn main() {
|
|||||||
commands::build(&options);
|
commands::build(&options);
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
error!("Please specify a subcommand!");
|
app.print_help().expect("Could not print help text to stdout!");
|
||||||
error!("Try 'rojo help' for information.");
|
|
||||||
process::exit(1);
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user