Skip to main content

conduit_cli/core/engine/workflow/
init.rs

1use crate::{
2    core::domain::loader::Loader,
3    core::engine::io::TomlFile,
4    core::engine::workflow::Workflow,
5    core::schemas::manifest::Manifest,
6    errors::{ConduitError, ConduitResult},
7};
8
9impl Workflow {
10    pub async fn create_project_manifest(
11        &self,
12        project_name: String,
13        minecraft: String,
14        loader: Loader,
15    ) -> ConduitResult<Manifest> {
16        let manifest_path = self.ctx.paths.manifest();
17
18        if manifest_path.exists() {
19            return Err(ConduitError::AlreadyInitialized(
20                "Project already initialized (conduit.toml exists)".to_string(),
21            ));
22        }
23
24        let mut manifest = Manifest::default();
25        manifest.project.name = project_name;
26        manifest.project.minecraft = minecraft;
27        manifest.project.loader = loader;
28
29        manifest.save(&manifest_path).await?;
30
31        Ok(manifest)
32    }
33}