1use std::{io::Write, path::PathBuf};
2
3use crate::{cli::CreateProject, debug, write_template};
4
5#[derive(Debug, Clone, Default)]
6pub struct Static {}
7
8impl CreateProject for Static {
9 fn create_project(&self, name: &str, path: &PathBuf) -> anyhow::Result<()> {
10 debug!("Creating static project {name:?} at {path:?}");
11
12 {
14 let path = path.join("Cup.toml");
15 let mut file = fs_err::File::create(path)?;
16 write_template!(file, "templates/Cup.toml" => [
17 NAME = name.to_string();
18 TYPE = "static".to_string();
19 ])?;
20 }
21
22 {
24 let path = path.join(".gitignore");
25 let mut file = fs_err::File::create(path)?;
26 write_template!(file, "templates/gitignore")?;
27 }
28
29 fs_err::create_dir(path.join("src"))?;
30 {
32 let path = path.join(format!("src/{}.cpp", name));
33 let mut file = fs_err::File::create(path)?;
34 write_template!(file, "templates/static.cpp" => [
35 NAME = name.to_string();
36 ])?;
37 }
38
39 fs_err::create_dir(path.join("include"))?;
40 {
42 let path = path.join(format!("include/{}.h", name));
43 let mut file = fs_err::File::create(path)?;
44 write_template!(file, "templates/static.h")?;
45 }
46
47 Ok(())
48 }
49}