solar_core/subcommand/
new.rs1use std::{fs, path::PathBuf};
2
3use clap::Parser;
4
5use crate::{Init, SolarError};
6
7#[derive(Parser, Clone)]
8pub struct New {
9 name: String,
11
12 #[arg(short, long, default_value = ".")]
14 destination: PathBuf,
15}
16
17impl New {
18 pub fn run(&self) -> Result<(), SolarError> {
19 let project_dir = self.destination.join(&self.name);
21 fs::create_dir_all(&project_dir)?;
22
23 let initializer: Init = Init::parse_from(vec![
25 "",
26 project_dir
27 .to_str()
28 .ok_or("Failed to convert destination path to string.")?,
29 ]);
30 initializer.run()?;
31
32 Ok(())
33 }
34}