trello-to-deck/src/init.rs

27 lines
682 B
Rust
Raw Normal View History

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