feat: add basic plan and project clone

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-08-24 00:45:16 +02:00
parent 6cb65e55c1
commit 531ea225f3
10 changed files with 256 additions and 28 deletions

View File

@@ -1,25 +1,66 @@
mod project;
use plan::Plan;
use project::ProjectPlan;
use project::Project;
mod plan;
mod project;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::fmt::init();
Cuddle::new().await?;
let _cuddle = Cuddle::default()
.prepare_project()
.await?
.prepare_plan()
.await?;
Ok(())
}
struct Cuddle {
project: Option<Project>,
struct Start {}
struct PrepareProject {
project: Option<ProjectPlan>,
}
impl Cuddle {
pub async fn new() -> anyhow::Result<Self> {
let project = Project::from_current_path().await?;
struct PreparePlan {
project: Option<ProjectPlan>,
plan: Option<Plan>,
}
Ok(Self { project })
struct Cuddle<S = Start> {
state: S,
}
// Cuddle maintains the context for cuddle to use
// Stage 1 figure out which state to display
// Stage 2 prepare plan
// Stage 3 validate settings, build actions, prepare
impl Cuddle {}
impl Cuddle<Start> {
pub fn default() -> Self {
Self { state: Start {} }
}
pub async fn prepare_project(&self) -> anyhow::Result<Cuddle<PrepareProject>> {
let project = ProjectPlan::from_current_path().await?;
Ok(Cuddle {
state: PrepareProject { project },
})
}
}
impl Cuddle<PrepareProject> {
pub async fn prepare_plan(&self) -> anyhow::Result<Cuddle<PreparePlan>> {
if let Some(project) = &self.state.project {
match Plan::new().clone_from_project(project).await? {
Some(plan) => todo!(),
None => todo!(),
}
}
todo!()
}
}