看起来好多了(

This commit is contained in:
shenjack 2024-01-21 18:27:12 +08:00
parent b474aa7ef9
commit 2c66abcf20
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 9 additions and 3 deletions

View File

@ -46,6 +46,7 @@ impl Config {
let args: Vec<String> = std::env::args().collect(); let args: Vec<String> = std::env::args().collect();
// 先检查有没有 --help // 先检查有没有 --help
if args.contains(&"--help".to_string()) { if args.contains(&"--help".to_string()) {
println!("v {}", crate::VERSION);
println!("{}", HELP_MESSAGE); println!("{}", HELP_MESSAGE);
return None; return None;
} }

View File

@ -1,6 +1,12 @@
use crate::config::Config; use crate::config::Config;
use winapi::um::wincon; use winapi::um::wincon;
fn free_console() {
unsafe {
wincon::FreeConsole();
}
}
pub fn call_bin(config: &Config) { pub fn call_bin(config: &Config) {
// 先切换工作目录 // 先切换工作目录
if let Some(chdir) = config.chdir.as_ref() { if let Some(chdir) = config.chdir.as_ref() {
@ -11,6 +17,7 @@ pub fn call_bin(config: &Config) {
.args(&config.bin_arg) .args(&config.bin_arg)
.spawn() .spawn()
.expect("执行失败"); .expect("执行失败");
free_console();
} }
pub fn run(config: &Config) { pub fn run(config: &Config) {
@ -19,9 +26,7 @@ pub fn run(config: &Config) {
std::thread::sleep(std::time::Duration::from_secs(2)); std::thread::sleep(std::time::Duration::from_secs(2));
println!("睡醒了"); println!("睡醒了");
// 尝试 FreeConsole 看看 // 尝试 FreeConsole 看看
unsafe { // free_console();
wincon::FreeConsole();
}
println!("FreeConsole 了"); println!("FreeConsole 了");
// 调用可执行文件 // 调用可执行文件
call_bin(&config); call_bin(&config);