| 419 | } |
| 420 | |
| 421 | fn current_executable_path() -> anyhow::Result<PathBuf> { |
| 422 | if let Some(arg0) = env::args_os().next().filter(|value| !value.is_empty()) { |
| 423 | let path = PathBuf::from(arg0); |
| 424 | let candidate = if path.is_absolute() { |
| 425 | path |
| 426 | } else { |
| 427 | env::current_dir() |
| 428 | .context("resolve current directory")? |
| 429 | .join(path) |
| 430 | }; |
| 431 | if candidate.exists() { |
| 432 | return Ok(candidate); |
| 433 | } |
| 434 | } |
| 435 | env::current_exe().context("resolve current executable path") |
| 436 | } |
| 437 | |
| 438 | fn argument_value(arguments: &[String], name: &str) -> Option<String> { |
| 439 | arguments |