看起来好多了(
This commit is contained in:
parent
b474aa7ef9
commit
2c66abcf20
@ -46,6 +46,7 @@ impl Config {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
// 先检查有没有 --help
|
||||
if args.contains(&"--help".to_string()) {
|
||||
println!("v {}", crate::VERSION);
|
||||
println!("{}", HELP_MESSAGE);
|
||||
return None;
|
||||
}
|
||||
|
11
src/win.rs
11
src/win.rs
@ -1,6 +1,12 @@
|
||||
use crate::config::Config;
|
||||
use winapi::um::wincon;
|
||||
|
||||
fn free_console() {
|
||||
unsafe {
|
||||
wincon::FreeConsole();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_bin(config: &Config) {
|
||||
// 先切换工作目录
|
||||
if let Some(chdir) = config.chdir.as_ref() {
|
||||
@ -11,6 +17,7 @@ pub fn call_bin(config: &Config) {
|
||||
.args(&config.bin_arg)
|
||||
.spawn()
|
||||
.expect("执行失败");
|
||||
free_console();
|
||||
}
|
||||
|
||||
pub fn run(config: &Config) {
|
||||
@ -19,9 +26,7 @@ pub fn run(config: &Config) {
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
println!("睡醒了");
|
||||
// 尝试 FreeConsole 看看
|
||||
unsafe {
|
||||
wincon::FreeConsole();
|
||||
}
|
||||
// free_console();
|
||||
println!("FreeConsole 了");
|
||||
// 调用可执行文件
|
||||
call_bin(&config);
|
||||
|
Loading…
Reference in New Issue
Block a user