Skip to main content

stout_cask/
lib.rs

1//! stout-cask: Cask installation and management for stout
2//!
3//! This crate handles:
4//! - Cask artifact downloading (DMG, PKG, ZIP)
5//! - macOS app installation (mount DMG, copy .app)
6//! - PKG installer execution
7//! - Quarantine attribute removal
8//! - Cask state tracking
9//! - Linux app support (AppImage, Flatpak)
10
11mod download;
12mod error;
13mod install;
14mod state;
15
16#[cfg(target_os = "macos")]
17mod macos;
18
19#[cfg(target_os = "linux")]
20mod linux;
21
22pub use download::{download_cask_artifact, ArtifactType};
23pub use error::{Error, Result};
24pub use install::{install_cask, uninstall_cask, CaskInstallOptions};
25pub use state::{InstalledCask, InstalledCasks};
26
27/// Detect the artifact type from a URL or path
28pub fn detect_artifact_type(url: &str) -> ArtifactType {
29    let url_lower = url.to_lowercase();
30
31    if url_lower.ends_with(".dmg") {
32        ArtifactType::Dmg
33    } else if url_lower.ends_with(".pkg") {
34        ArtifactType::Pkg
35    } else if url_lower.ends_with(".zip") {
36        ArtifactType::Zip
37    } else if url_lower.ends_with(".tar.gz") || url_lower.ends_with(".tgz") {
38        ArtifactType::TarGz
39    } else if url_lower.ends_with(".tar.bz2") || url_lower.ends_with(".tbz2") {
40        ArtifactType::TarBz2
41    } else if url_lower.ends_with(".appimage") {
42        ArtifactType::AppImage
43    } else {
44        // Default to ZIP for unknown
45        ArtifactType::Zip
46    }
47}