2024-11-29 14:31:40 +00:00
|
|
|
//
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use color_eyre::eyre::{eyre, Result};
|
|
|
|
|
|
|
|
use crate::{f, p, s, template, Ctx, NAME};
|
|
|
|
|
|
|
|
pub(crate) fn run(ctx: &Ctx) -> Result<()> {
|
|
|
|
let path = ctx.fs.base().join(f!("{NAME}.toml"));
|
|
|
|
let file = ctx.fs.file(&path);
|
|
|
|
|
|
|
|
if file.exists()? {
|
|
|
|
Err(eyre!("File already exists - not overwriting: {file}"))
|
|
|
|
} else {
|
|
|
|
file.write(include_str!("default-config.toml"))?;
|
|
|
|
p!(
|
2024-12-07 10:05:37 +00:00
|
|
|
ctx.prt,
|
2024-11-29 14:31:40 +00:00
|
|
|
"{}",
|
|
|
|
template::expand(
|
|
|
|
include_str!("post-init-instructions.txt"),
|
|
|
|
HashMap::from([("NAME", NAME), ("file", s!(file).as_str())])
|
|
|
|
)
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|