Get the template directory relative to the executable
| 234 | |
| 235 | // Get the template directory relative to the executable |
| 236 | static fs::path get_template_dir(TemplateType template_type) |
| 237 | { |
| 238 | fs::path exe_dir = get_executable_dir(); |
| 239 | if (exe_dir.empty()) |
| 240 | { |
| 241 | return fs::path(); |
| 242 | } |
| 243 | |
| 244 | // Determine which template to use |
| 245 | std::string template_name; |
| 246 | switch (template_type) |
| 247 | { |
| 248 | case TemplateType::Pkg: |
| 249 | template_name = "pkg"; |
| 250 | break; |
| 251 | case TemplateType::App: |
| 252 | default: |
| 253 | template_name = "app"; |
| 254 | break; |
| 255 | } |
| 256 | |
| 257 | // The coi binary is at repo root, templates/ is a sibling |
| 258 | fs::path tpl_dir = exe_dir / "templates" / template_name; |
| 259 | if (fs::exists(tpl_dir)) |
| 260 | { |
| 261 | return tpl_dir; |
| 262 | } |
| 263 | |
| 264 | return fs::path(); |
| 265 | } |
| 266 | |
| 267 | // Replace __PLACEHOLDER__ patterns in a string |
| 268 | static std::string replace_placeholders(const std::string &content, |
no test coverage detected