feat: add context

This commit is contained in:
Kasper Juul Hermansen 2025-02-14 22:43:49 +01:00
parent e5053ecabd
commit 074f7caf01
Signed by: kjuulh
SSH Key Fingerprint: SHA256:RjXh0p7U6opxnfd3ga/Y9TCo18FYlHFdSpRIV72S/QM
3 changed files with 17 additions and 4 deletions

View File

@ -5,7 +5,7 @@ use kdl::KdlDocument;
use rusty_s3::{Bucket, Credentials, S3Action}; use rusty_s3::{Bucket, Credentials, S3Action};
use crate::{ use crate::{
model::{Plan, Project}, model::{Context, Plan, Project},
plan_reconciler::PlanReconciler, plan_reconciler::PlanReconciler,
state::SharedState, state::SharedState,
}; };
@ -70,16 +70,22 @@ pub async fn execute() -> anyhow::Result<()> {
let project: Project = project_doc.try_into()?; let project: Project = project_doc.try_into()?;
tracing::trace!("found a project name: {}", project.name); tracing::trace!("found a project name: {}", project.name);
if let Some(plan_file_path) = PlanReconciler::new() let plan = if let Some(plan_file_path) = PlanReconciler::new()
.reconcile(&project, &project_path) .reconcile(&project, &project_path)
.await? .await?
{ {
let plan_file = tokio::fs::read_to_string(&plan_file_path).await?; let plan_file = tokio::fs::read_to_string(&plan_file_path).await?;
let plan_doc: KdlDocument = plan_file.parse()?; let plan_doc: KdlDocument = plan_file.parse()?;
let project: Plan = plan_doc.try_into()?; let plan: Plan = plan_doc.try_into()?;
tracing::trace!("found a plan name: {}", project.name); tracing::trace!("found a plan name: {}", project.name);
}
Some(plan)
} else {
None
};
let context = Context { project, plan };
} }
Commands::Serve { Commands::Serve {

View File

@ -2,6 +2,12 @@ use std::path::PathBuf;
use kdl::{KdlDocument, KdlNode, KdlValue}; use kdl::{KdlDocument, KdlNode, KdlValue};
#[derive(Debug, Clone)]
pub struct Context {
pub project: Project,
pub plan: Option<Plan>,
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Plan { pub struct Plan {
pub name: String, pub name: String,

View File

@ -0,0 +1 @@
hyperlog-lock