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