use clap::Parser;
use std::{fs, path::PathBuf, process::Command};
#[derive(Parser, Debug, Default)]
pub struct New {
name: String,
#[arg(short, long, default_value = ".")]
path: PathBuf,
#[arg(short, long, name = "no-git")]
nogit: bool,
}
impl New {
pub fn run(&self) -> anyhow::Result<()> {
let target = self.path.join(self.name.clone());
let mut git = Command::new("git");
git.args([
"clone",
"https://github.com/spacejamapp/service-template.git",
"--depth=1",
]);
git.arg(target.clone());
git.status()?;
if self.nogit {
fs::remove_file(target.join(".git")).ok();
fs::remove_file(target.join(".gitignore")).ok();
fs::remove_file(target.join(".github")).ok();
}
Ok(())
}
}