diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-28 12:35:07 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-28 12:35:07 +0800 |
| commit | afddded8fdab6925a83f1240999ebac8f76f239d (patch) | |
| tree | 16d692f32e15824863907156ad1d4ed8c7b29576 /gen/gen_iscc_script.rs | |
| parent | a469c6684619c9677dfc1125886acc37f24c81d4 (diff) | |
Replace manual template processing with just_template library
Diffstat (limited to 'gen/gen_iscc_script.rs')
| -rw-r--r-- | gen/gen_iscc_script.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/gen/gen_iscc_script.rs b/gen/gen_iscc_script.rs index 1eddcca..23328ab 100644 --- a/gen/gen_iscc_script.rs +++ b/gen/gen_iscc_script.rs @@ -1,25 +1,36 @@ use std::path::PathBuf; +use just_template::{Template, tmpl_param}; + use crate::r#gen::{ constants::{SETUP_JV_CLI_ISS, SETUP_JV_CLI_ISS_TEMPLATE}, env::{get_author, get_site, get_version}, }; -/// Generate Inno Setup installer script (Windows only) +/// Generate Inno Setup installer script (Windows only) using just_template pub async fn generate_installer_script(repo_root: &PathBuf) { let template_path = repo_root.join(SETUP_JV_CLI_ISS_TEMPLATE); let output_path = repo_root.join(SETUP_JV_CLI_ISS); - let template = tokio::fs::read_to_string(&template_path).await.unwrap(); + // Read the template + let template_content = tokio::fs::read_to_string(&template_path).await.unwrap(); + // Get values for the template let author = get_author().unwrap(); let version = get_version(); let site = get_site().unwrap(); - let generated = template - .replace("<<<AUTHOR>>>", &author) - .replace("<<<VERSION>>>", &version) - .replace("<<<SITE>>>", &site); + // Create template + let mut template = Template::from(template_content); + + // Set all parameters + tmpl_param!(template, version = version, author = author, site = site); + // Expand the template + let generated = template.expand().unwrap(); + + // Write the generated script tokio::fs::write(output_path, generated).await.unwrap(); + + println!("Generated Inno Setup script using just_template"); } |
