feat: Allow validate-template to accept a local directory path
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 41s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m9s

This commit is contained in:
j
2026-03-07 20:47:28 +13:00
parent 83a55bbed0
commit 178f8fa179

View File

@@ -435,14 +435,24 @@ int validate_handler(const CommandContext& ctx) {
return 1;
}
// Get template info
template_info tinfo = gTemplateManager().get_template_info(template_name);
if (!tinfo.is_set()) {
error << "Template not found: " << template_name << std::endl;
return 1;
}
std::filesystem::path template_path;
std::filesystem::path template_path = tinfo.local_template_path();
// Check if the argument is a path to a template directory
std::filesystem::path arg_path(template_name);
if (arg_path.is_relative())
arg_path = std::filesystem::current_path() / arg_path;
if (std::filesystem::is_directory(arg_path) && std::filesystem::exists(arg_path / "template_info.env")) {
template_path = std::filesystem::canonical(arg_path);
template_name = template_path.filename().string();
} else {
// Look up by name via template manager
template_info tinfo = gTemplateManager().get_template_info(template_name);
if (!tinfo.is_set()) {
error << "Template not found: " << template_name << std::endl;
return 1;
}
template_path = tinfo.local_template_path();
}
maketitle("Validating template: " + template_name);
info << "Path: " << template_path.string() << std::endl;