1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use crate::utils::Collection;

pub fn template(collections: &Vec<Collection>) -> String {
    let cargo_content_without_collections = format!("[package]\n\
        name = \"znap-server\"\n\
        version = \"0.1.2\"\n\
        edition = \"2021\"\n\
        \n[dependencies]\n\
        tokio = {{ version = \"1\", features = [\"full\"] }}\n\
        axum = \"0.7\"\n\
    ");
    let collection_dependencies: Vec<String> = collections
        .iter()
        .map(|collection| {
            format!(
                "{} = {{ path = \"{}\" }}",
                collection.name, collection.path.to_str().unwrap()
            )
        })
        .collect();
    let collection_dependencies_joined = collection_dependencies.join("\n");

    format!(
        "{}{}",
        cargo_content_without_collections, collection_dependencies_joined
    )
}