init now creates overrides dir and gitignore

This commit is contained in:
LordMZTE 2021-09-01 20:11:54 +02:00
parent f4e2694e43
commit d95755b194

View file

@ -38,6 +38,10 @@ use url::Url;
use crate::config::Config;
const DEFAULT_CONFIG: &[u8] = include_bytes!("../../assets/modpacktoolsconfig.toml");
const DEFAULT_GITIGNORE: &str = "\
build/
.mpt/
";
pub async fn run(
modpack_name: String,
@ -139,7 +143,8 @@ pub async fn run(
)?;
}
tokio::fs::create_dir_all(path).await?;
// also create overrides
tokio::fs::create_dir_all(path.join("overrides")).await?;
let data = serde_json::to_vec_pretty(&Manifest {
// TODO rename this to snake_case
@ -182,5 +187,21 @@ pub async fn run(
))?;
}
if Path::new(".gitignore").exists() {
stdout.execute(PrintStyledContent(
".gitignore exists, skipping...\n"
.with(Color::Red)
.attribute(Attribute::Italic),
))?;
} else {
tokio::fs::write(".gitignore", DEFAULT_GITIGNORE).await?;
stdout.execute(PrintStyledContent(
"Created .gitignore!\n"
.with(Color::Green)
.attribute(Attribute::Bold),
))?;
}
Ok(())
}