feat: implement basic workspace

This commit is contained in:
2025-03-20 08:19:18 +01:00
parent f98b48667c
commit bd927840d6
6 changed files with 133 additions and 77 deletions

View File

@@ -372,3 +372,40 @@ impl TryFrom<KdlDocument> for Project {
})
}
}
#[derive(Debug, Clone, Serialize)]
pub struct Workspace {}
impl TryFrom<KdlDocument> for Workspace {
type Error = anyhow::Error;
fn try_from(value: KdlDocument) -> Result<Self, Self::Error> {
Ok(Self {})
}
}
#[derive(Debug, Clone, Serialize)]
pub enum ForestFile {
Workspace(Workspace),
Project(Project),
}
impl TryFrom<KdlDocument> for ForestFile {
type Error = anyhow::Error;
fn try_from(value: KdlDocument) -> Result<Self, Self::Error> {
if value.get("workspace").is_some() && value.get("project").is_some() {
anyhow::bail!("a forest.kdl file cannot contain both a workspace and project")
}
if value.get("project").is_some() {
return Ok(Self::Project(value.try_into()?));
}
if value.get("workspace").is_some() {
return Ok(Self::Workspace(value.try_into()?));
}
anyhow::bail!("a forest.kdl file must be either a project, workspace or plan")
}
}