use crate::{result::Result, template};
use clap::Parser;
#[derive(Clone, Debug, Parser)]
pub struct New {
#[arg(short, long, default_value = "dapp-template")]
pub template: String,
pub path: Option<String>,
}
impl New {
pub async fn exec(&self) -> Result<()> {
let templates = template::list().await?;
let template = &self.template;
if templates.contains(template) {
let path = self.path.as_deref().unwrap_or(template);
template::download(template, path).await?;
println!("Successfully created {path}!");
} else {
println!("Template not found, available templates: {templates:#?}");
}
Ok(())
}
}