arcbox-cli 0.4.9

Command-line interface for ArcBox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! App-bundle path detection for the bundled xbin directory.
//!
//! The privileged `/usr/local/bin/*` symlinks are managed by `arcbox-helper`
//! (`server::mutations::cli`); the user-space `~/.arcbox/bin/*` symlinks are
//! managed by `setup::link_docker_tools_to_user_bin`. This module exists only
//! to share the xbin-detection helper between those code paths.

use std::path::PathBuf;

/// Detects the `xbin/` directory inside the current app bundle.
///
/// When `abctl` runs from `Contents/MacOS/bin/abctl`, xbin is at
/// `Contents/MacOS/xbin/`. Returns `None` outside an app bundle.
pub fn detect_bundle_xbin() -> Option<PathBuf> {
    let exe = std::env::current_exe().ok()?;
    let xbin = exe.parent()?.parent()?.join("xbin");
    xbin.is_dir().then_some(xbin)
}