Move Rojo server into root of the repository

This commit is contained in:
Lucien Greathouse
2019-08-27 16:56:52 -07:00
parent ec9afba029
commit 6f7dbe99fe
48 changed files with 50 additions and 54 deletions

49
src/commands/init.rs Normal file
View File

@@ -0,0 +1,49 @@
use std::path::PathBuf;
use failure::Fail;
use crate::project::{Project, ProjectInitError};
#[derive(Debug, Fail)]
pub enum InitError {
#[fail(
display = "Invalid project kind '{}', valid kinds are 'place' and 'model'",
_0
)]
InvalidKind(String),
#[fail(display = "Project init error: {}", _0)]
ProjectInitError(#[fail(cause)] ProjectInitError),
}
impl_from!(InitError {
ProjectInitError => ProjectInitError,
});
#[derive(Debug)]
pub struct InitOptions<'a> {
pub fuzzy_project_path: PathBuf,
pub kind: Option<&'a str>,
}
pub fn init(options: &InitOptions) -> Result<(), InitError> {
let (project_path, project_kind) = match options.kind {
Some("place") | None => {
let path = Project::init_place(&options.fuzzy_project_path)?;
(path, "place")
}
Some("model") => {
let path = Project::init_model(&options.fuzzy_project_path)?;
(path, "model")
}
Some(invalid) => return Err(InitError::InvalidKind(invalid.to_string())),
};
println!(
"Created new {} project file at {}",
project_kind,
project_path.display()
);
Ok(())
}