feat: expose the plan model from the reconciler
This commit is contained in:
@@ -2,6 +2,36 @@ use std::path::PathBuf;
|
||||
|
||||
use kdl::{KdlDocument, KdlNode, KdlValue};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Plan {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl TryFrom<KdlDocument> for Plan {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: KdlDocument) -> Result<Self, Self::Error> {
|
||||
let plan_section = value.get("plan").ok_or(anyhow::anyhow!(
|
||||
"forest.kdl plan file must have a plan object"
|
||||
))?;
|
||||
|
||||
let plan_children = plan_section
|
||||
.children()
|
||||
.ok_or(anyhow::anyhow!("a forest plan must have children"))?;
|
||||
|
||||
Ok(Self {
|
||||
name: plan_children
|
||||
.get_arg("name")
|
||||
.and_then(|n| match n {
|
||||
KdlValue::String(s) => Some(s),
|
||||
_ => None,
|
||||
})
|
||||
.cloned()
|
||||
.ok_or(anyhow::anyhow!("a forest kuddle plan must have a name"))?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ProjectPlan {
|
||||
Local { path: PathBuf },
|
||||
|
||||
Reference in New Issue
Block a user