use crate::error::app::Errors;
use anyhow::Result;
use inquire::Select;
use std::path::PathBuf;
use tokio::fs;
pub async fn init(path: &PathBuf) -> Result<(), Errors> {
let config_bytes = include_bytes!("katharsis.toml");
if path.try_exists()? {
let options: Vec<&str> = vec!["Yes", "No"];
let ans: &str = Select::new("A katharsis.toml already exists in the current directory. Do you want to overwrite it?", options).prompt()?;
if ans == "yes" {
fs::write(path, config_bytes).await?;
}
} else {
fs::write(path, config_bytes).await?;
}
Ok(())
}