use std::path::{absolute, PathBuf};
use crate::config::default_config;
#[derive(clap::Args)]
#[command(about = "Create a new Bular project in an existing directory")]
pub struct Command {}
impl Command {
pub async fn run(&self, cwd: PathBuf) {
let bular_id = None;
let cwd = absolute(cwd).unwrap();
let path = cwd.join("bular.yaml");
if path.exists() {
eprintln!("Already found a bular configuration. Please delete it and try again!");
std::process::exit(1);
}
println!("{:?}", path);
let name = cwd.file_name().unwrap().to_str().unwrap().to_string();
std::fs::write(
path,
serde_yaml::to_string(&default_config(name, bular_id)).unwrap(),
)
.unwrap();
println!("Done!");
}
}