Rewrite Project, remove SourceProject (#274)

* Rewrite project file to have relative paths and drop SourceProject

* Redo project error types

* Tidy up and document Project type

* Strip out init command
This commit is contained in:
Lucien Greathouse
2019-12-12 14:45:15 -08:00
committed by GitHub
parent 47c7f63d75
commit 1f7f2b22e7
16 changed files with 233 additions and 539 deletions

View File

@@ -8,7 +8,7 @@ use failure::Fail;
use crate::{
cli::BuildCommand,
common_setup,
project::ProjectLoadError,
project::ProjectError,
vfs::{FsError, RealFetcher, Vfs, WatchMode},
};
@@ -47,7 +47,7 @@ pub enum BuildError {
BinaryModelEncodeError(rbx_binary::EncodeError),
#[fail(display = "{}", _0)]
ProjectLoadError(#[fail(cause)] ProjectLoadError),
ProjectError(#[fail(cause)] ProjectError),
#[fail(display = "{}", _0)]
FsError(#[fail(cause)] FsError),
@@ -57,7 +57,7 @@ impl_from!(BuildError {
io::Error => IoError,
rbx_xml::EncodeError => XmlModelEncodeError,
rbx_binary::EncodeError => BinaryModelEncodeError,
ProjectLoadError => ProjectLoadError,
ProjectError => ProjectError,
FsError => FsError,
});

View File

@@ -1,37 +1,17 @@
use failure::Fail;
use crate::{
cli::{InitCommand, InitKind},
project::{Project, ProjectInitError},
};
use crate::{cli::InitCommand, project::ProjectError};
#[derive(Debug, Fail)]
pub enum InitError {
#[fail(display = "Project init error: {}", _0)]
ProjectInitError(#[fail(cause)] ProjectInitError),
ProjectError(#[fail(cause)] ProjectError),
}
impl_from!(InitError {
ProjectInitError => ProjectInitError,
ProjectError => ProjectError,
});
pub fn init(options: InitCommand) -> Result<(), InitError> {
let (project_path, project_kind) = match options.kind {
InitKind::Place => {
let path = Project::init_place(&options.path)?;
(path, "place")
}
InitKind::Model => {
let path = Project::init_model(&options.path)?;
(path, "model")
}
};
println!(
"Created new {} project file at {}",
project_kind,
project_path.display()
);
Ok(())
pub fn init(_options: InitCommand) -> Result<(), InitError> {
unimplemented!("init command");
}

View File

@@ -8,7 +8,7 @@ use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor};
use crate::{
cli::ServeCommand,
project::ProjectLoadError,
project::ProjectError,
serve_session::ServeSession,
vfs::{RealFetcher, Vfs, WatchMode},
web::LiveServer,
@@ -19,11 +19,11 @@ const DEFAULT_PORT: u16 = 34872;
#[derive(Debug, Fail)]
pub enum ServeError {
#[fail(display = "Couldn't load project: {}", _0)]
ProjectLoad(#[fail(cause)] ProjectLoadError),
ProjectError(#[fail(cause)] ProjectError),
}
impl_from!(ServeError {
ProjectLoadError => ProjectLoad,
ProjectError => ProjectError,
});
pub fn serve(options: ServeCommand) -> Result<(), ServeError> {