oxide_cli/templates/
loader.rs1use std::path::Path;
2
3use anyhow::Result;
4
5use crate::{
6 AppContext,
7 cache::is_template_installed,
8 templates::{TemplateFile, install::install_template},
9 utils::fs::read_dir_to_files,
10};
11
12pub async fn get_files(ctx: &AppContext, template_name: &str) -> Result<Vec<TemplateFile>> {
13 let path = Path::new(template_name);
14 if !is_template_installed(ctx, template_name)? {
15 install_template(ctx, template_name).await?;
16 }
17
18 let files = read_dir_to_files(&ctx.paths.templates.join(path))?;
19
20 Ok(files)
21}