MCPcopy Create free account
hub / github.com/VSCodeConfigHelper/v4 / generate

Function generate

src-tauri/src/tasks/test.rs:71–120  ·  view source on GitHub ↗
(args: &TaskArgs)

Source from the content-addressed store, hash-verified

69use key::*;
70
71pub fn generate(args: &TaskArgs) -> Result<()> {
72 macro_rules! cmt {
73 ( $( $x:expr ),* ) => {
74 &(if args.is_c { c_comment } else { cpp_comment })(&format!($( $x ),*))
75 };
76 }
77 let test_file = args.test_file.as_ref().unwrap();
78
79 debug!("生成测试文件 {}...", test_file);
80
81 let helloworld = if args.is_c { &C_HELLOWORLD } else { &CPP_HELLOWORLD };
82
83 let run_key = if args.compatible_mode {
84 format!("{}{}F5", CTRL, SEP)
85 } else {
86 "F6".to_string()
87 };
88
89 fs::write(
90 test_file,
91 &[
92 cmt!("VS Code C/C++ 测试代码 \"Hello World\""),
93 cmt!("由 VSCodeConfigHelper v{} 生成", env!("CARGO_PKG_VERSION")),
94 "",
95 cmt!(
96 "您可以在当前文件夹(工作文件夹)下新建 .{} 源文件编写代码。",
97 args.file_ext
98 ),
99 "",
100 cmt!("按下 {} 编译运行。", run_key),
101 cmt!("按下 F5 编译调试。"),
102 cmt!("按下 {}{}{}{}B 编译。", CTRL_CMD, SEP, SHIFT, SEP),
103 helloworld,
104 cmt!("此文件编译运行将输出 \"Hello, world!\"。"),
105 cmt!("按下 {} 后,你将在弹出的终端窗口中看到这一行字。", run_key),
106 cmt!(
107 "{}",
108 if args.setup.id == compiler::Id::MinGW {
109 "!! 重要提示:请您在编写代码前,确认文件名不含中文或特殊字符。 !!"
110 } else {
111 ""
112 }
113 ),
114 cmt!("若遇到问题,请联系开发者 guyutongxue@163.com。"),
115 ]
116 .join("\n"),
117 )?;
118 debug!("测试文件 {} 生成成功。", test_file);
119 Ok(())
120}

Callers

nothing calls this directly

Calls 1

to_stringMethod · 0.80

Tested by

no test coverage detected