aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/src/main.rs81
1 files changed, 44 insertions, 37 deletions
diff --git a/launcher/src/main.rs b/launcher/src/main.rs
index 8fdeea1..8d1d6c5 100644
--- a/launcher/src/main.rs
+++ b/launcher/src/main.rs
@@ -2,8 +2,7 @@ use std::path::{Path, PathBuf};
use std::process;
fn get_home() -> PathBuf {
- dirs::home_dir()
- .unwrap_or(PathBuf::from("/"))
+ dirs::home_dir().unwrap_or(PathBuf::from("/"))
}
#[cfg(target_os = "macos")]
@@ -34,7 +33,7 @@ fn get_search_paths() -> [PathBuf; 5] {
PathBuf::from("/System/Library/Frameworks/AtomicRuntime.framework"),
PathBuf::from("/usr/local/lib/atomic-runtime"),
PathBuf::from("/opt/atomic-runtime"),
- get_home_search()
+ get_home_search(),
]
}
@@ -48,7 +47,7 @@ fn get_search_paths() -> [PathBuf; 8] {
PathBuf::from("/lib/atomic-runtime"),
PathBuf::from("/lib64/atomic-runtime"),
PathBuf::from("/opt/atomic-runtime"),
- get_home_search()
+ get_home_search(),
]
}
@@ -83,12 +82,16 @@ fn get_search_paths() -> [PathBuf; 29] {
PathBuf::from("C:\\Program Files (Arm)\\Atomic Runtime"),
PathBuf::from("C:\\ProgramData\\AtomicRuntime"),
PathBuf::from("C:\\ProgramData\\Atomic Runtime"),
- get_home_search()
+ get_home_search(),
]
}
fn show_system_info() {
- println!("atomic-launcher: Starting atomic-launcher on {} ({})", std::env::consts::OS, std::env::consts::ARCH);
+ println!(
+ "atomic-launcher: Starting atomic-launcher on {} ({})",
+ std::env::consts::OS,
+ std::env::consts::ARCH
+ );
}
// TODO: Rename these to "Atomic"
@@ -110,16 +113,18 @@ const APP_DATA_PATH: &str = "./resources/app";
fn main() {
show_system_info();
- println!("atomic-launcher: Compiled against rustc {}", rustc_version_runtime::version());
+ println!(
+ "atomic-launcher: Compiled against rustc {}",
+ rustc_version_runtime::version()
+ );
let exec_path = std::env::current_exe().ok();
- let work_dir = exec_path.as_ref()
- .and_then(|p| p.parent())
- .unwrap_or(Path::new("/"));
+ let work_dir = exec_path.as_ref().and_then(|p| p.parent()).unwrap();
- println!("atomic-launcher: Current directory: {}", work_dir
- .to_str()
- .unwrap());
+ println!(
+ "atomic-launcher: Current directory: {}",
+ work_dir.to_str().unwrap()
+ );
let mut found_app = false;
let mut app_path = PathBuf::from(work_dir);
@@ -128,21 +133,24 @@ fn main() {
if app_path.exists() {
found_app = true;
} else {
- println!("atomic-launcher: Warning: Could not find Electron-compatible app. Looked in {}. The default atomic-runtime application will be opened instead.", app_path
- .to_str()
- .unwrap());
+ println!(
+ "atomic-launcher: Warning: Could not find Electron-compatible app.\
+ Looked in {}. The default atomic-runtime application will be opened instead.",
+ app_path.to_str().unwrap()
+ );
}
let runtime_search_paths = get_search_paths();
- println!("atomic-launcher: Looking for atomic-runtime in: {}", runtime_search_paths
- .iter()
- .map(|i| i
- .to_str()
- .unwrap())
- .collect::<Vec<&str>>()
- .join(", ")
- .as_str());
+ println!(
+ "atomic-launcher: Looking for atomic-runtime in: {}",
+ runtime_search_paths
+ .iter()
+ .map(|i| i.to_str().unwrap())
+ .collect::<Vec<&str>>()
+ .join(", ")
+ .as_str()
+ );
let mut valid_path: Option<PathBuf> = None;
for path in runtime_search_paths {
@@ -154,14 +162,17 @@ fn main() {
}
if let Some(path) = valid_path {
- println!("atomic-launcher: Found atomic-runtime at {}", Path::new(&format!("{}/{}", path
- .to_str()
- .unwrap_or(""), BINARY_PATH))
- .to_str()
- .unwrap_or(""));
- let mut cmd = process::Command::new(Path::new(&format!("{}/{}", path
- .to_str()
- .unwrap_or(""), BINARY_PATH)));
+ println!(
+ "atomic-launcher: Found atomic-runtime at {}",
+ Path::new(&format!("{}/{}", path.to_str().unwrap(), BINARY_PATH))
+ .to_str()
+ .unwrap()
+ );
+ let mut cmd = process::Command::new(Path::new(&format!(
+ "{}/{}",
+ path.to_str().unwrap(),
+ BINARY_PATH
+ )));
println!("atomic-launcher: Executing: {:?}", cmd);
if found_app {
@@ -169,15 +180,11 @@ fn main() {
}
if let Ok(mut app) = cmd.spawn() {
- process::exit(app.wait()
- .unwrap_or_default()
- .code()
- .unwrap_or(255));
+ process::exit(app.wait().unwrap_or_default().code().unwrap_or(255));
} else {
eprintln!("atomic-launcher: Application failed to start.");
process::exit(3);
}
-
} else {
eprintln!("atomic-launcher: Could not find a valid atomic-runtime path. Aborting.");
process::exit(2);