From 137c41af5336d06351d95a37788401dd093efe19 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 23 Jan 2026 02:37:58 +0800 Subject: Fix: convert renderer_list to .rs to stop RA false errors --- .gitignore | 2 +- build.rs | 6 +++--- src/cmd/cmd_system.rs | 6 +----- templates/renderer_list.rs.template | 16 ++++++++++++++++ templates/renderer_list.txt | 16 ---------------- 5 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 templates/renderer_list.rs.template delete mode 100644 templates/renderer_list.txt diff --git a/.gitignore b/.gitignore index 07a06bf..4ecb8ca 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ /src/data/compile_info.rs /setup/windows/setup_jv_cli.iss /src/cmd/cmds/_registry.rs -/src/cmd/renderers/renderer_list.txt +/src/cmd/renderers/renderer_list.rs diff --git a/build.rs b/build.rs index 7763be2..f657a7f 100644 --- a/build.rs +++ b/build.rs @@ -11,8 +11,8 @@ const SETUP_JV_CLI_ISS_TEMPLATE: &str = "./templates/setup_jv_cli.iss"; const REGISTRY_RS: &str = "./src/cmd/cmds/_registry.rs"; const REGISTRY_RS_TEMPLATE: &str = "./templates/_registry.rs.template"; -const RENDERER_LIST_TEMPLATE: &str = "./templates/renderer_list.txt"; -const RENDERER_LIST: &str = "./src/cmd/renderers/renderer_list.txt"; +const RENDERER_LIST_TEMPLATE: &str = "./templates/renderer_list.rs.template"; +const RENDERER_LIST: &str = "./src/cmd/renderers/renderer_list.rs"; const REGISTRY_TOML: &str = "./Registry.toml"; @@ -387,7 +387,7 @@ fn generate_renderer_list_file(repo_root: &PathBuf) -> Result<(), Box>", name) - .replace("<>", renderer_type) + .replace("RendererType", renderer_type) .trim_matches('\n') .to_string() }) diff --git a/src/cmd/cmd_system.rs b/src/cmd/cmd_system.rs index 229c7f0..9696947 100644 --- a/src/cmd/cmd_system.rs +++ b/src/cmd/cmd_system.rs @@ -25,7 +25,6 @@ where fn get_help_str() -> String; /// Process the command with a specified renderer, performing any necessary post-execution processing - #[rustfmt::skip] fn process_with_renderer_flag( args: Vec, ctx: JVCommandContext, @@ -36,10 +35,7 @@ where { async move { let renderer_str = renderer.as_str(); - include!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/src/cmd/renderers/renderer_list.txt" - )) + include!("renderers/renderer_list.rs") } } diff --git a/templates/renderer_list.rs.template b/templates/renderer_list.rs.template new file mode 100644 index 0000000..37f0f1b --- /dev/null +++ b/templates/renderer_list.rs.template @@ -0,0 +1,16 @@ +match renderer_str { +// MATCH +// -- TEMPLATE START -- + "<>" => { + Self::process_with_renderer::< + RendererType + >(args, ctx) + .await + } +// -- TEMPLATE END -- + _ => { + return Err(CmdProcessError::Render(CmdRenderError::RendererNotFound( + renderer_str.to_string(), + ))); + } +} diff --git a/templates/renderer_list.txt b/templates/renderer_list.txt deleted file mode 100644 index cfc8105..0000000 --- a/templates/renderer_list.txt +++ /dev/null @@ -1,16 +0,0 @@ -match renderer_str { -// MATCH -// -- TEMPLATE START -- - "<>" => { - Self::process_with_renderer::< - <>, - >(args, ctx) - .await - } -// -- TEMPLATE END -- - _ => { - return Err(CmdProcessError::Render(CmdRenderError::RendererNotFound( - renderer, - ))); - } -} -- cgit