@@ -122,7 +122,7 @@ impl ConvertCommand {
122122 std:: fs:: read_to_string ( template_path) . map_err ( |e| ConvertError :: IoError ( e) ) ?;
123123 template_engine. process_template ( & template_content) ?
124124 } else {
125- Self :: generate_default_config ( & template_engine) ?
125+ Self :: generate_default_config ( & template_engine, output_protocol ) ?
126126 } ;
127127
128128 // Get output format and filename based on protocol
@@ -222,12 +222,17 @@ impl ConvertCommand {
222222 }
223223 }
224224
225- /// generate default config template (sing-box format)
225+ /// generate default config template based on output protocol
226226 fn generate_default_config (
227227 template_engine : & template_engine:: TemplateEngine ,
228+ output_protocol : & OutputProtocol ,
228229 ) -> Result < String > {
229- // Get default sing-box template from the protocol module
230- let template_str = singbox:: generate_default_template ( ) ;
230+ // Get default template from the protocol module based on output protocol
231+ let template_str = match output_protocol {
232+ OutputProtocol :: SingBox => singbox:: generate_default_template ( ) ,
233+ OutputProtocol :: Clash => protocols:: clash:: generate_default_template ( ) ,
234+ OutputProtocol :: V2Ray => protocols:: v2ray:: generate_default_template ( ) ,
235+ } ;
231236
232237 // Process template to replace interpolation rules like {{ALL-TAG}}
233238 template_engine. process_template ( & template_str)
@@ -292,24 +297,11 @@ pub async fn handle_convert(
292297
293298 let output_protocol = OutputProtocol :: from_str ( output_protocol_str) . ok_or_else ( || {
294299 ConvertError :: ConfigValidationError ( format ! (
295- "不支持的输出协议 : {},支持的协议 : sing-box(singbox), clash, v2ray。当前仅支持 sing-box " ,
300+ "Unsupported output protocol : {}, supported protocols : sing-box(singbox), clash, v2ray" ,
296301 output_protocol_str
297302 ) )
298303 } ) ?;
299304
300- // 验证当前仅支持 sing-box
301- match output_protocol {
302- OutputProtocol :: SingBox => {
303- // 允许
304- }
305- OutputProtocol :: Clash | OutputProtocol :: V2Ray => {
306- return Err ( ConvertError :: ConfigValidationError ( format ! (
307- "输出协议 {} 暂不支持,当前仅支持 sing-box" ,
308- output_protocol_str
309- ) ) ) ;
310- }
311- }
312-
313305 // 合并 output:CLI > 配置文件 > 默认值
314306 let final_output: Option < String > = output
315307 . as_ref ( )
0 commit comments