fn create_file_if_not_present(
    filename: &Path,
    contents: &str,
    name: &str,
) -> Result<(), InitError> {
    let filename_str = filename.to_str().unwrap();
    if fs::metadata(filename).is_ok() {
        eprintln!("[WARNING]: Didn't create '{}', since it already exists. If you didn't mean for this to happen, you should remove this file and try again.", filename_str);
    } else {
        let contents = contents
            .replace("%name", name)
            .replace("%perseus_version", env!("CARGO_PKG_VERSION"));
        fs::write(filename, contents).map_err(|err| InitError::CreateInitFileFailed {
            source: err,
            filename: filename_str.to_string(),
        })?;
    }
    Ok(())
}
Creates the named file with the given contents if it doesn't already exist,
printing a warning if it does.
packages/perseus-cli/src/init.rs