MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / run

Function run

cli/src/init.rs:17–47  ·  view source on GitHub ↗
(name: Option<&str>, bare: bool)

Source from the content-addressed store, hash-verified

15}
16
17pub fn run(name: Option<&str>, bare: bool) -> Result<()> {
18 let dir = name.unwrap_or(".");
19 let root = Path::new(dir);
20
21 if dir != "." {
22 if root.exists() {
23 bail!("'{dir}' already exists");
24 }
25 fs::create_dir_all(root).with_context(|| format!("creating {dir}"))?;
26 }
27
28 fs::write(root.join("main.py"), MAIN_PY)?;
29 fs::write(root.join("packages.json"), PACKAGES_JSON)?;
30
31 let mut items = vec![];
32 if !bare {
33 let title = if dir == "." { "edge app" } else { dir };
34 fs::write(root.join("index.html"), index_html(title))?;
35 items.push("index.html");
36 }
37 items.push("main.py");
38 items.push("packages.json");
39
40 let next = if dir == "." {
41 "edge serve".to_string()
42 } else {
43 format!("cd {dir} && edge serve")
44 };
45 crate::ui::scaffolded(dir, &items, &next);
46 Ok(())
47}

Callers

nothing calls this directly

Calls 3

scaffoldedFunction · 0.85
pushMethod · 0.80
index_htmlFunction · 0.70

Tested by

no test coverage detected