(name: Option<&str>, bare: bool)
| 15 | } |
| 16 | |
| 17 | pub 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 | } |
nothing calls this directly
no test coverage detected