Skip to main content

conduit_cli/core/engine/manager/
export.rs

1use std::path::PathBuf;
2
3use crate::{
4    core::{
5        engine::{
6            io::{IncludeFile, conduit::ConduitModpackManager},
7            manager::ProjectManager,
8        },
9        schemas::{include::ConduitInclude, modpacks::modrinth::ModrinthIndex},
10    },
11    errors::ConduitResult,
12};
13
14#[derive(Debug, Clone)]
15pub enum ModpackType {
16    Conduit,
17    Mrpack { index: ModrinthIndex },
18}
19
20impl ProjectManager {
21    pub async fn export(
22        &self,
23        modpack_type: ModpackType,
24        path: PathBuf,
25    ) -> ConduitResult<ConduitModpackManager> {
26        let manifest = self.ctx.manifest.read().await.clone();
27        let lock = self.ctx.lockfile.read().await.clone();
28
29        let modpack = match modpack_type {
30            ModpackType::Conduit => {
31                let ignore = ConduitInclude::load(self.ctx.paths.include()).await?;
32                ConduitModpackManager::new(
33                    path,
34                    manifest,
35                    lock,
36                    ignore,
37                    &self.project_root.clone(),
38                )?
39            }
40            #[allow(unused)]
41            ModpackType::Mrpack { index } => {
42                unimplemented!();
43            }
44        };
45
46        Ok(modpack)
47    }
48}