use std::{fs, path::PathBuf};
use clap::Parser;
use crate::{Init, SolarError};
#[derive(Parser, Clone)]
pub struct New {
name: String,
#[arg(short, long, default_value = ".")]
destination: PathBuf,
}
impl New {
pub fn run(&self) -> Result<(), SolarError> {
let project_dir = self.destination.join(&self.name);
fs::create_dir_all(&project_dir)?;
let initializer: Init = Init::parse_from(vec![
"",
project_dir
.to_str()
.ok_or("Failed to convert destination path to string.")?,
]);
initializer.run()?;
Ok(())
}
}