Skip to content

Commit 0171dbb

Browse files
committed
fix: mod init
1 parent d0c92db commit 0171dbb

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

crates/league-mod/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ eyre = "0.6.12"
99
toml = "0.8.19"
1010
mod-project = { path = "../mod-project" }
1111
regex = "1.11.1"
12+
serde_json = "1.0"

crates/league-mod/src/commands/init.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,30 @@ fn create_mod_project_file(
4040
mod_project_dir_path: impl AsRef<Path>,
4141
args: &InitModProjectArgs,
4242
) -> eyre::Result<()> {
43-
let mod_project = ModProject {
44-
name: args.name.clone(),
45-
display_name: match args.display_name {
46-
Some(ref display_name) => display_name.clone(),
47-
None => args.name.clone(),
48-
},
49-
version: "0.1.0".to_string(),
50-
description: "".to_string(),
51-
authors: vec![ModProjectAuthor::Name("<Your Name>".to_string())],
52-
};
43+
let mod_project =
44+
create_default_mod_project(Some(args.name.clone()), args.display_name.clone());
5345

54-
let mod_project_file_content = toml::to_string(&mod_project)?;
46+
let mod_project_file_content = serde_json::to_string(&mod_project)?;
5547
std::fs::write(
56-
mod_project_dir_path.as_ref().join("modproject.toml"),
48+
mod_project_dir_path.as_ref().join("mod.config.json"),
5749
mod_project_file_content,
5850
)?;
5951

6052
Ok(())
6153
}
6254

55+
fn create_default_mod_project(name: Option<String>, display_name: Option<String>) -> ModProject {
56+
ModProject {
57+
name: name.unwrap_or("mod-name".to_string()),
58+
display_name: display_name.unwrap_or("Mod Name".to_string()),
59+
version: "0.1.0".to_string(),
60+
description: "Short description of the mod".to_string(),
61+
authors: vec![ModProjectAuthor::Name("<Your Name>".to_string())],
62+
transformers: vec![],
63+
layers: vec![],
64+
}
65+
}
66+
6367
fn create_mod_project_dir_path(name: impl AsRef<Path>) -> io::Result<PathBuf> {
6468
Ok(std::path::Path::new(&std::env::current_dir()?).join(name))
6569
}

0 commit comments

Comments
 (0)