Skip to main content

conduit_cli/core/
initializer.rs

1use crate::core::filesystem::config::ConduitConfig;
2use crate::core::error::CoreResult;
3use crate::core::filesystem::lock::ConduitLock;
4use crate::core::paths::CorePaths;
5
6pub struct InitParams {
7    pub name: Option<String>,
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(v) = params.mc_version {
19        config.mc_version = v;
20    }
21    if let Some(l) = params.loader {
22        config.loader = l;
23    }
24
25    ConduitLock::save_config(paths, &config)?;
26    Ok(config)
27}