调整代码顺序

This commit is contained in:
lubeilin
2023-05-11 20:56:55 +08:00
parent ea5ba750d4
commit 675e0c52ff
2 changed files with 17 additions and 20 deletions
+17 -5
View File
@@ -146,13 +146,25 @@ fn main() {
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn main() {
let home = dirs::home_dir().unwrap().join(".switch_desktop");
config::set_home(home);
let args = BaseArgs::parse();
if let Commands::Start(start_args) = &args.command {
if start_args.log {
let _ = log_init();
match args.command {
Commands::Start(_) | Commands::Stop => {
if sudo::RunningAs::Root != sudo::check() {
println!(
"{}",
style("需要使用root权限执行(Need to execute with root permission)...").red()
);
sudo::escalate_if_needed().unwrap();
}
let home = dirs::home_dir().unwrap().join(".switch_desktop");
config::set_home(home);
if let Commands::Start(start_args) = &args.command {
if start_args.log {
let _ = log_init();
}
}
}
_ => {}
}
unix::main0(args);
}