use std::fs;
use std::path::Path;
use crate::error::AppError;
const UNPAID_EXAMPLE: &str =
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/unpaid.example.toml"));
pub(crate) fn run(path: &Path) -> Result<(), AppError> {
if path.exists() {
return Err(AppError::AlreadyExists {
path: path.to_path_buf(),
});
}
fs::write(path, UNPAID_EXAMPLE).map_err(|source| AppError::Write {
path: path.to_path_buf(),
source,
})?;
#[allow(
clippy::print_stdout,
reason = "init reports the written path to the operator"
)]
{
println!("wrote {}", path.display());
}
Ok(())
}