26 lines
682 B
Rust
26 lines
682 B
Rust
//
|
|
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!(
|
|
ctx.prt,
|
|
"{}",
|
|
template::expand(
|
|
include_str!("post-init-instructions.txt"),
|
|
HashMap::from([("NAME", NAME), ("file", s!(file).as_str())])
|
|
)
|
|
);
|
|
Ok(())
|
|
}
|
|
}
|