Skip to main content

conduit_cli/core/
initializer.rs

1use crate::core::error::CoreResult;
2use crate::core::io::project::{ConduitConfig, InstanceType, ProjectFiles};
3use crate::core::paths::CorePaths;
4
5pub struct InitParams {
6    pub name: Option<String>,
7    pub instance_type: Option<InstanceType>,
8    pub mc_version: Option<String>,
9    pub loader: Option<String>,
10}
11
12pub fn init_project(paths: &CorePaths, params: InitParams) -> CoreResult<ConduitConfig> {
13    let mut config = ConduitConfig::default();
14
15    if let Some(n) = params.name {
16        config.name = n;
17    }
18    if let Some(t) = params.instance_type {
19        config.instance_type = t;
20    }
21    if let Some(v) = params.mc_version {
22        config.mc_version = v;
23    }
24    if let Some(l) = params.loader {
25        config.loader = l;
26    }
27
28    ProjectFiles::save_manifest(paths, &config)?;
29
30    Ok(config)
31}