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 | |
| parent | a469c6684619c9677dfc1125886acc37f24c81d4 (diff) | |
Replace manual template processing with just_template library
| -rw-r--r-- | Cargo.lock | 10 | ||||
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | gen/gen_commands_file.rs | 99 | ||||
| -rw-r--r-- | gen/gen_compile_info.rs | 32 | ||||
| -rw-r--r-- | gen/gen_iscc_script.rs | 23 | ||||
| -rw-r--r-- | gen/gen_override_renderer.rs | 71 | ||||
| -rw-r--r-- | gen/gen_renderers_file.rs | 58 | ||||
| -rw-r--r-- | gen/gen_specific_renderer.rs | 74 | ||||
| -rw-r--r-- | rust-analyzer.toml | 6 | ||||
| -rw-r--r-- | templates/_commands.rs.template | 35 | ||||
| -rw-r--r-- | templates/_override_renderer_dispatcher.rs.template | 13 | ||||
| -rw-r--r-- | templates/_override_renderer_entry.rs.template | 15 | ||||
| -rw-r--r-- | templates/_specific_renderer_matching.rs.template | 17 | ||||
| -rw-r--r-- | templates/compile_info.rs.template | 14 | ||||
| -rw-r--r-- | templates/setup_jv_cli.iss.template | 6 |
15 files changed, 206 insertions, 268 deletions
@@ -1150,6 +1150,7 @@ dependencies = [ "erased-serde", "just_enough_vcs", "just_fmt", + "just_template", "log", "regex", "render_system_macros", @@ -1171,6 +1172,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e" [[package]] +name = "just_template" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28f77e78b7de1bd14c242241bbd802efd1e4b7a3717ea5f2eb05aba5e069d8b9" +dependencies = [ + "just_fmt", +] + +[[package]] name = "jvlib" version = "0.1.0" dependencies = [ @@ -42,6 +42,7 @@ tokio = { version = "1", features = ["rt", "rt-multi-thread"] } chrono = "0.4" toml = "0.9" regex = "1.12" +just_template = "0.1.0" [dependencies] # Just Enough VCS diff --git a/gen/gen_commands_file.rs b/gen/gen_commands_file.rs index 4131154..b68ac0a 100644 --- a/gen/gen_commands_file.rs +++ b/gen/gen_commands_file.rs @@ -1,33 +1,32 @@ use std::path::PathBuf; use just_fmt::pascal_case; +use just_template::{Template, tmpl, tmpl_param}; -use crate::r#gen::constants::{ - COMMAND_LIST, COMMAND_LIST_TEMPLATE, COMMANDS_PATH, REGISTRY_TOML, TEMPLATE_END, TEMPLATE_START, -}; +use crate::r#gen::constants::{COMMAND_LIST, COMMAND_LIST_TEMPLATE, COMMANDS_PATH, REGISTRY_TOML}; -/// Generate registry file from Registry.toml configuration +/// Generate registry file from Registry.toml configuration using just_template pub async fn generate_commands_file(repo_root: &PathBuf) { let template_path = repo_root.join(COMMAND_LIST_TEMPLATE); let output_path = repo_root.join(COMMAND_LIST); let config_path = repo_root.join(REGISTRY_TOML); // Read the template - let template = tokio::fs::read_to_string(&template_path).await.unwrap(); + let template_content = tokio::fs::read_to_string(&template_path).await.unwrap(); // Read and parse the TOML configuration let config_content = tokio::fs::read_to_string(&config_path).await.unwrap(); let config: toml::Value = toml::from_str(&config_content).unwrap(); // Collect all command configurations - let mut commands = Vec::new(); - let mut nodes = Vec::new(); + let mut all_commands: Vec<(String, String, String)> = Vec::new(); + let mut all_nodes: Vec<String> = Vec::new(); // Collect commands from registry.toml and COMMANDS_PATH in parallel let (registry_collected, auto_collected) = tokio::join!( async { - let mut commands = Vec::new(); - let mut nodes = Vec::new(); + let mut commands: Vec<(String, String, String)> = Vec::new(); + let mut nodes: Vec<String> = Vec::new(); let Some(table) = config.as_table() else { return (commands, nodes); @@ -70,8 +69,8 @@ pub async fn generate_commands_file(repo_root: &PathBuf) { (commands, nodes) }, async { - let mut commands = Vec::new(); - let mut nodes = Vec::new(); + let mut commands: Vec<(String, String, String)> = Vec::new(); + let mut nodes: Vec<String> = Vec::new(); let commands_dir = repo_root.join(COMMANDS_PATH); if commands_dir.exists() && commands_dir.is_dir() { let mut entries = tokio::fs::read_dir(&commands_dir).await.unwrap(); @@ -120,69 +119,43 @@ pub async fn generate_commands_file(repo_root: &PathBuf) { let (mut registry_commands, mut registry_nodes) = registry_collected; let (mut auto_commands, mut auto_nodes) = auto_collected; - commands.append(&mut registry_commands); - commands.append(&mut auto_commands); - nodes.append(&mut registry_nodes); - nodes.append(&mut auto_nodes); - - // Extract the node_if template from the template content - const PROCESS_MARKER: &str = "// PROCESS"; - const LINE: &str = "<<LINE>>"; - const NODES: &str = "<<NODES>>"; - - let template_start_index = template - .find(TEMPLATE_START) - .ok_or("Template start marker not found") - .unwrap(); - let template_end_index = template - .find(TEMPLATE_END) - .ok_or("Template end marker not found") - .unwrap(); - - let template_slice = &template[template_start_index..template_end_index + TEMPLATE_END.len()]; - let node_if_template = template_slice - .trim_start_matches(TEMPLATE_START) - .trim_end_matches(TEMPLATE_END) - .trim_matches('\n'); - - // Generate the match arms for each command - let match_arms: String = commands - .iter() - .map(|(key, node, cmd_type)| { - node_if_template - .replace("<<KEY>>", key) - .replace("<<NODE_NAME>>", node) - .replace("<<COMMAND_TYPE>>", cmd_type) - .trim_matches('\n') - .to_string() - }) - .collect::<Vec<_>>() - .join("\n"); + all_commands.append(&mut registry_commands); + all_commands.append(&mut auto_commands); + + all_nodes.append(&mut registry_nodes); + all_nodes.append(&mut auto_nodes); + + // Create template + let mut template = Template::from(template_content); + + for (key, node, cmd_type) in &all_commands { + tmpl!(template += { + command_match_arms { + (key = key, node_name = node, cmd_type = cmd_type) + } + }); + } let nodes_str = format!( "[\n {}\n ]", - nodes + all_nodes .iter() .map(|node| format!("\"{}\".to_string()", node)) .collect::<Vec<_>>() .join(", ") ); - // Replace the template section with the generated match arms - let final_content = template - .replace(node_if_template, "") - .replace(TEMPLATE_START, "") - .replace(TEMPLATE_END, "") - .replace(PROCESS_MARKER, &match_arms) - .lines() - .filter(|line| !line.trim().is_empty()) - .collect::<Vec<_>>() - .join("\n") - .replace(LINE, "") - .replace(NODES, nodes_str.as_str()); + // Use insert_param for the NODES parameter + tmpl_param!(template, nodes = nodes_str); + + // Expand the template + let final_content = template.expand().unwrap(); // Write the generated code tokio::fs::write(output_path, final_content).await.unwrap(); - println!("Generated registry file with {} commands", commands.len()); + println!( + "Generated registry file with {} commands using just_template", + all_commands.len() + ); } diff --git a/gen/gen_compile_info.rs b/gen/gen_compile_info.rs index 5af030c..8d68d89 100644 --- a/gen/gen_compile_info.rs +++ b/gen/gen_compile_info.rs @@ -1,17 +1,20 @@ use std::path::PathBuf; +use just_template::{Template, tmpl_param}; + use crate::r#gen::{ constants::{COMPILE_INFO_RS, COMPILE_INFO_RS_TEMPLATE}, env::{get_git_branch, get_git_commit, get_platform, get_toolchain, get_version}, }; -/// Generate compile info +/// Generate compile info using just_template pub async fn generate_compile_info(repo_root: &PathBuf) { // Read the template code let template_code = tokio::fs::read_to_string(repo_root.join(COMPILE_INFO_RS_TEMPLATE)) .await .unwrap(); + // Get all the values needed for the template let date = chrono::Local::now().format("%Y-%m-%d %H:%M:%S").to_string(); let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string()); let platform = get_platform(&target); @@ -20,18 +23,29 @@ pub async fn generate_compile_info(repo_root: &PathBuf) { let branch = get_git_branch().unwrap_or_else(|_| "unknown".to_string()); let commit = get_git_commit().unwrap_or_else(|_| "unknown".to_string()); - let generated_code = template_code - .replace("{date}", &date) - .replace("{target}", &target) - .replace("{platform}", &platform) - .replace("{toolchain}", &toolchain) - .replace("{version}", &version) - .replace("{branch}", &branch) - .replace("{commit}", &commit); + // Create a Template instance + let mut template = Template::from(template_code); + + // Set all parameters + tmpl_param!( + template, + date = date, + target = target, + platform = platform, + toolchain = toolchain, + version = version, + branch = branch, + commit = commit + ); + + // Expand the template + let generated_code = template.expand().unwrap(); // Write the generated code let compile_info_path = repo_root.join(COMPILE_INFO_RS); tokio::fs::write(compile_info_path, generated_code) .await .unwrap(); + + println!("Generated compile_info.rs using just_template"); } 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"); } diff --git a/gen/gen_override_renderer.rs b/gen/gen_override_renderer.rs index dafca91..1e67be4 100644 --- a/gen/gen_override_renderer.rs +++ b/gen/gen_override_renderer.rs @@ -1,13 +1,11 @@ use std::{collections::HashSet, path::PathBuf}; +use just_template::{Template, tmpl}; use regex::Regex; use tokio::fs; use crate::r#gen::{ - constants::{ - COMMANDS_PATH, OVERRIDE_RENDERER_ENTRY, OVERRIDE_RENDERER_ENTRY_TEMPLATE, TEMPLATE_END, - TEMPLATE_START, - }, + constants::{COMMANDS_PATH, OVERRIDE_RENDERER_ENTRY, OVERRIDE_RENDERER_ENTRY_TEMPLATE}, resolve_types::resolve_type_paths, }; @@ -17,53 +15,30 @@ pub async fn generate_override_renderer(repo_root: &PathBuf) { let all_possible_types = collect_all_possible_types(&PathBuf::from(COMMANDS_PATH)).await; // Read the template - let template = tokio::fs::read_to_string(&template_path).await.unwrap(); - - // Extract the template section from the template content - const MATCH_MARKER: &str = "// MATCHING"; - - let template_start_index = template - .find(TEMPLATE_START) - .ok_or("Template start marker not found") - .unwrap(); - let template_end_index = template - .find(TEMPLATE_END) - .ok_or("Template end marker not found") - .unwrap(); - - let template_slice = &template[template_start_index..template_end_index + TEMPLATE_END.len()]; - let renderer_template = template_slice - .trim_start_matches(TEMPLATE_START) - .trim_end_matches(TEMPLATE_END) - .trim_matches('\n'); - - // Generate the match arms for each renderer - let match_arms: String = all_possible_types - .iter() - .map(|type_name| { - let name = type_name.split("::").last().unwrap_or(type_name); - renderer_template - .replace("JVOutputTypeName", name) - .replace("JVOutputType", type_name) - .trim_matches('\n') - .to_string() - }) - .collect::<Vec<String>>() - .join("\n"); - - // Replace the template section with the generated match arms - let final_content = template - .replace(renderer_template, "") - .replace(TEMPLATE_START, "") - .replace(TEMPLATE_END, "") - .replace(MATCH_MARKER, &match_arms) - .lines() - .filter(|line| !line.trim().is_empty()) - .collect::<Vec<_>>() - .join("\n"); + let template_content = tokio::fs::read_to_string(&template_path).await.unwrap(); + + // Create template + let mut template = Template::from(template_content); + + for type_name in &all_possible_types { + let name = type_name.split("::").last().unwrap_or(type_name); + tmpl!(template += { + type_match_arms { + (jv_output_type_name = name, jv_output_type = type_name) + } + }); + } + + // Expand the template + let final_content = template.expand().unwrap(); // Write the generated code tokio::fs::write(output_path, final_content).await.unwrap(); + + println!( + "Generated override renderer entry with {} types using just_template", + all_possible_types.len() + ); } pub async fn collect_all_possible_types(dir: &PathBuf) -> HashSet<String> { diff --git a/gen/gen_renderers_file.rs b/gen/gen_renderers_file.rs index 497d258..f16c504 100644 --- a/gen/gen_renderers_file.rs +++ b/gen/gen_renderers_file.rs @@ -1,18 +1,19 @@ use std::path::PathBuf; +use just_template::{Template, tmpl}; + use crate::r#gen::constants::{ OVERRIDE_RENDERER_DISPATCHER, OVERRIDE_RENDERER_DISPATCHER_TEMPLATE, REGISTRY_TOML, - TEMPLATE_END, TEMPLATE_START, }; -/// Generate renderer list file from Registry.toml configuration +/// Generate renderer list file from Registry.toml configuration using just_template pub async fn generate_renderers_file(repo_root: &PathBuf) { let template_path = repo_root.join(OVERRIDE_RENDERER_DISPATCHER_TEMPLATE); let output_path = repo_root.join(OVERRIDE_RENDERER_DISPATCHER); let config_path = repo_root.join(REGISTRY_TOML); // Read the template - let template = tokio::fs::read_to_string(&template_path).await.unwrap(); + let template_content = tokio::fs::read_to_string(&template_path).await.unwrap(); // Read and parse the TOML configuration let config_content = tokio::fs::read_to_string(&config_path).await.unwrap(); @@ -45,53 +46,24 @@ pub async fn generate_renderers_file(repo_root: &PathBuf) { renderers.push((name.to_string(), renderer_type.to_string())); } - // Extract the template section from the template content - const MATCH_MARKER: &str = "// MATCH"; - - let template_start_index = template - .find(TEMPLATE_START) - .ok_or("Template start marker not found") - .unwrap(); - let template_end_index = template - .find(TEMPLATE_END) - .ok_or("Template end marker not found") - .unwrap(); + // Create template + let mut template = Template::from(template_content); - let template_slice = &template[template_start_index..template_end_index + TEMPLATE_END.len()]; - let renderer_template = template_slice - .trim_start_matches(TEMPLATE_START) - .trim_end_matches(TEMPLATE_END) - .trim_matches('\n'); - - // Generate the match arms for each renderer - let match_arms: String = renderers - .iter() - .map(|(name, renderer_type)| { - renderer_template - .replace("<<NAME>>", name) - .replace("RendererType", renderer_type) - .trim_matches('\n') - .to_string() - }) - .collect::<Vec<String>>() - .join("\n"); + for (name, renderer_type) in &renderers { + tmpl!(template += { + renderer_match_arms { + (name = name, renderer_type = renderer_type) + } + }); + } - // Replace the template section with the generated match arms - let final_content = template - .replace(renderer_template, "") - .replace(TEMPLATE_START, "") - .replace(TEMPLATE_END, "") - .replace(MATCH_MARKER, &match_arms) - .lines() - .filter(|line| !line.trim().is_empty()) - .collect::<Vec<_>>() - .join("\n"); + let final_content = template.expand().unwrap(); // Write the generated code tokio::fs::write(output_path, final_content).await.unwrap(); println!( - "Generated renderer list file with {} renderers", + "Generated renderer list file with {} renderers using just_template", renderers.len() ); } diff --git a/gen/gen_specific_renderer.rs b/gen/gen_specific_renderer.rs index 0c66631..95e6900 100644 --- a/gen/gen_specific_renderer.rs +++ b/gen/gen_specific_renderer.rs @@ -1,78 +1,50 @@ use std::{collections::HashMap, path::PathBuf}; +use just_template::{Template, tmpl}; use regex::Regex; use crate::r#gen::{ - constants::{ - RENDERERS_PATH, SPECIFIC_RENDERER_MATCHING, SPECIFIC_RENDERER_MATCHING_TEMPLATE, - TEMPLATE_END, TEMPLATE_START, - }, + constants::{RENDERERS_PATH, SPECIFIC_RENDERER_MATCHING, SPECIFIC_RENDERER_MATCHING_TEMPLATE}, resolve_types::resolve_type_paths, }; const RENDERER_TYPE_PREFIX: &str = "crate::"; +/// Generate specific renderer matching file using just_template pub async fn generate_specific_renderer(repo_root: &PathBuf) { - // Matches - // HashMap<RendererTypeFullName, OutputTypeFullName> + // Matches: HashMap<RendererTypeFullName, OutputTypeFullName> let mut renderer_matches: HashMap<String, String> = HashMap::new(); let renderer_path = repo_root.join(RENDERERS_PATH); - collect_renderers(&renderer_path, &mut renderer_matches); let template_path = repo_root.join(SPECIFIC_RENDERER_MATCHING_TEMPLATE); let output_path = repo_root.join(SPECIFIC_RENDERER_MATCHING); // Read the template - let template = tokio::fs::read_to_string(&template_path).await.unwrap(); - - // Extract the template section from the template content - const MATCH_MARKER: &str = "// MATCHING"; - - let template_start_index = template - .find(TEMPLATE_START) - .ok_or("Template start marker not found") - .unwrap(); - let template_end_index = template - .find(TEMPLATE_END) - .ok_or("Template end marker not found") - .unwrap(); - - let template_slice = &template[template_start_index..template_end_index + TEMPLATE_END.len()]; - let renderer_template = template_slice - .trim_start_matches(TEMPLATE_START) - .trim_end_matches(TEMPLATE_END) - .trim_matches('\n'); - - // Generate the match arms for each renderer - let match_arms: String = renderer_matches - .iter() - .map(|(renderer, output)| { - let output_name = output.split("::").last().unwrap_or(output); - renderer_template - .replace("OutputTypeName", output_name) - .replace("OutputType", output) - .replace("RendererType", renderer) - .trim_matches('\n') - .to_string() - }) - .collect::<Vec<String>>() - .join("\n"); + let template_content = tokio::fs::read_to_string(&template_path).await.unwrap(); - // Replace the template section with the generated match arms - let final_content = template - .replace(renderer_template, "") - .replace(TEMPLATE_START, "") - .replace(TEMPLATE_END, "") - .replace(MATCH_MARKER, &match_arms) - .lines() - .filter(|line| !line.trim().is_empty()) - .collect::<Vec<_>>() - .join("\n"); + // Create template + let mut template = Template::from(template_content); + + for (renderer, output) in &renderer_matches { + let output_name = output.split("::").last().unwrap_or(output); + tmpl!(template += { + renderer_match_arms { + (output_type_name = output_name, output_type = output, renderer_type = renderer) + } + }); + } + + let final_content = template.expand().unwrap(); // Write the generated code tokio::fs::write(output_path, final_content).await.unwrap(); + + println!( + "Generated specific renderer matching with {} renderers using just_template", + renderer_matches.len() + ); } fn collect_renderers(dir_path: &PathBuf, matches: &mut HashMap<String, String>) { diff --git a/rust-analyzer.toml b/rust-analyzer.toml index 0a09afa..1df6f98 100644 --- a/rust-analyzer.toml +++ b/rust-analyzer.toml @@ -27,6 +27,12 @@ check.command = "clippy" check.extraArgs = ["--all-features"] files.watcher = "client" +files.excludeDirs = [ + "src/systems/cmd/_commands.rs", + "src/systems/render/_override_renderer_dispatcher.rs", + "src/systems/render/_override_renderer_entry.rs", + "src/systems/render/_specific_renderer_matching.rs" +] macroExpansion.mode = "hir" macroExpansion.maxDepth = 32 diff --git a/templates/_commands.rs.template b/templates/_commands.rs.template index 84d2db4..c11e312 100644 --- a/templates/_commands.rs.template +++ b/templates/_commands.rs.template @@ -1,7 +1,7 @@ // Auto generated by build.rs use crate::systems::cmd::cmd_system::{JVCommand, JVCommandContext}; use crate::systems::cmd::errors::CmdProcessError; -<<LINE>> + /// Input parameters, execute a command node pub async fn jv_cmd_process_node( node: &str, @@ -10,17 +10,27 @@ pub async fn jv_cmd_process_node( renderer_override: String ) -> Result<crate::systems::render::renderer::JVRenderResult, crate::systems::cmd::errors::CmdProcessError> { match node { -// PROCESS -// -- TEMPLATE START -- - // Command `<<KEY>>` - "<<NODE_NAME>>" => { +>>>>>>>>>> command_match_arms + _ => {} + } + return Err(CmdProcessError::NoNodeFound(node.to_string())); +} + +/// Get all command nodes +pub fn jv_cmd_nodes() -> Vec<String> { + vec!<<<nodes>>> +} + +@@@ >>> command_match_arms + // Command `<<<key>>>` + "<<<node_name>>>" => { if renderer_override == "default" { - return crate::<<COMMAND_TYPE>>::process_to_render_system( + return crate::<<<cmd_type>>>::process_to_render_system( args, ctx, ) .await; } else { - return crate::<<COMMAND_TYPE>>::process_to_renderer_override( + return crate::<<<cmd_type>>>::process_to_renderer_override( args, ctx, renderer_override, @@ -28,13 +38,4 @@ pub async fn jv_cmd_process_node( .await; } } -// -- TEMPLATE END -- - _ => {} - } - return Err(CmdProcessError::NoNodeFound(node.to_string())); -} -<<LINE>> -/// Get all command nodes -pub fn jv_cmd_nodes() -> Vec<String> { - vec!<<NODES>> -} +@@@ <<< diff --git a/templates/_override_renderer_dispatcher.rs.template b/templates/_override_renderer_dispatcher.rs.template index 80cabb6..dd4f016 100644 --- a/templates/_override_renderer_dispatcher.rs.template +++ b/templates/_override_renderer_dispatcher.rs.template @@ -1,14 +1,15 @@ // Auto generated by build.rs match renderer { -// MATCH -// -- TEMPLATE START -- - "<<NAME>>" => { - RendererType::render(&concrete_data).await - } -// -- TEMPLATE END -- +>>>>>>>>>> renderer_match_arms _ => { return Err(CmdProcessError::Render(CmdRenderError::RendererNotFound( renderer.to_string(), ))); } } + +@@@ >>> renderer_match_arms + "<<<name>>>" => { + <<<renderer_type>>>::render(&concrete_data).await + } +@@@ <<< diff --git a/templates/_override_renderer_entry.rs.template b/templates/_override_renderer_entry.rs.template index 7912cb0..d9089c9 100644 --- a/templates/_override_renderer_entry.rs.template +++ b/templates/_override_renderer_entry.rs.template @@ -1,13 +1,14 @@ // Auto generated by build.rs match type_id { -// MATCHING -// -- TEMPLATE START -- - type_id if type_id == std::any::TypeId::of::<JVOutputType>() => { +>>>>>>>>>> type_match_arms + _ => Err(CmdProcessError::NoMatchingCommand) +} + +@@@ >>> type_match_arms + type_id if type_id == std::any::TypeId::of::<<<<jv_output_type>>>>() => { let concrete_data = data - .downcast::<JVOutputType>() + .downcast::<<<<jv_output_type>>>>() .map_err(|_| CmdProcessError::DowncastFailed)?; include!("../render/_override_renderer_dispatcher.rs").map_err(CmdProcessError::Render) }, -// -- TEMPLATE END -- - _ => Err(CmdProcessError::NoMatchingCommand) -} +@@@ <<< diff --git a/templates/_specific_renderer_matching.rs.template b/templates/_specific_renderer_matching.rs.template index 4f1c7d2..bd41406 100644 --- a/templates/_specific_renderer_matching.rs.template +++ b/templates/_specific_renderer_matching.rs.template @@ -1,12 +1,13 @@ // Auto generated by build.rs match type_id { -// MATCHING -// -- TEMPLATE START -- - type_id if type_id == std::any::TypeId::of::<OutputType>() => { - RendererType::render( - &data.downcast::<OutputType>() - .unwrap()).await - }, -// -- TEMPLATE END -- +>>>>>>>>>> renderer_match_arms _ => Err(CmdRenderError::RendererNotFound(format!("{:?}", type_id))) } + +@@@ >>> renderer_match_arms + type_id if type_id == std::any::TypeId::of::<<<<output_type>>>>() => { + <<<renderer_type>>>::render( + &data.downcast::<<<<output_type>>>>() + .unwrap()).await + }, +@@@ <<< diff --git a/templates/compile_info.rs.template b/templates/compile_info.rs.template index b65055b..fcaaf63 100644 --- a/templates/compile_info.rs.template +++ b/templates/compile_info.rs.template @@ -12,13 +12,13 @@ pub struct CompileInfo { impl Default for CompileInfo { fn default() -> Self { Self { - date: "{date}".to_string(), - target: "{target}".to_string(), - platform: "{platform}".to_string(), - toolchain: "{toolchain}".to_string(), - cli_version: "{version}".to_string(), - build_branch: "{branch}".to_string(), - build_commit: "{commit}".to_string(), + date: "<<<date>>>".to_string(), + target: "<<<target>>>".to_string(), + platform: "<<<platform>>>".to_string(), + toolchain: "<<<toolchain>>>".to_string(), + cli_version: "<<<version>>>".to_string(), + build_branch: "<<<branch>>>".to_string(), + build_commit: "<<<commit>>>".to_string(), } } } diff --git a/templates/setup_jv_cli.iss.template b/templates/setup_jv_cli.iss.template index 6306ced..ae1c40f 100644 --- a/templates/setup_jv_cli.iss.template +++ b/templates/setup_jv_cli.iss.template @@ -1,7 +1,7 @@ #define MyAppName "JustEnoughVCS" -#define MyAppVersion "<<<VERSION>>>" -#define MyAppPublisher "<<<AUTHOR>>>" -#define MyAppURL "<<<SITE>>>" +#define MyAppVersion "<<<version>>>" +#define MyAppPublisher "<<<author>>>" +#define MyAppURL "<<<site>>>" [Setup] AppId={{8265DF21-F290-487E-9403-C2730EC31A03} |
