Skip to main content

actr_cli/templates/python/
echo.rs

1use crate::error::Result;
2use crate::templates::ProjectTemplate;
3use std::collections::HashMap;
4use std::path::Path;
5
6pub fn load(files: &mut HashMap<String, String>) -> Result<()> {
7    let fixtures_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures");
8    let python_fixtures = fixtures_root.join("python/echo");
9
10    // Note: proto files are no longer created during init, they will be pulled via actr install
11    ProjectTemplate::load_file(
12        &python_fixtures.join("Actr.server.toml.jinja2"),
13        files,
14        "server/Actr.toml",
15    )?;
16    ProjectTemplate::load_file(
17        &python_fixtures.join("Actr.client.toml.jinja2"),
18        files,
19        "client/Actr.toml",
20    )?;
21    ProjectTemplate::load_file(
22        &python_fixtures.join("server.py.jinja2"),
23        files,
24        "server/server.py",
25    )?;
26    ProjectTemplate::load_file(
27        &python_fixtures.join("client.py.jinja2"),
28        files,
29        "client/client.py",
30    )?;
31    ProjectTemplate::load_file(
32        &python_fixtures.join("README.md.jinja2"),
33        files,
34        "README.md",
35    )?;
36    ProjectTemplate::load_file(
37        &python_fixtures.join("gitignore.jinja2"),
38        files,
39        ".gitignore",
40    )?;
41
42    // Load proto templates
43    let proto_fixtures = fixtures_root.join("protos");
44
45    // Server: echo service definition
46    ProjectTemplate::load_file(
47        &proto_fixtures.join("echo_service.hbs"),
48        files,
49        "server/protos/local/echo.proto",
50    )?;
51
52    // Client: empty local.proto
53    ProjectTemplate::load_file(
54        &proto_fixtures.join("local.echo.hbs"),
55        files,
56        "client/protos/local/local.proto",
57    )?;
58
59    Ok(())
60}