cnf-lib 0.6.0

Distribution-agnostic 'command not found'-handler
Documentation
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: (C) 2023 Andreas Hartmann <hartan@7x.de>
// This file is part of cnf-lib, available at <https://gitlab.com/hartang/rust/cnf>

//! # Container Environment Handler
//!
//! This runs ad-hoc containers from local container storage or a remote container registry if
//! configured.
//!
//! **This is not currently implemented but planned for later on. If you have a need for this
//! feature, please let us know!**

use crate::error::CnfError;
use std::path::Path;

const CONTAINER_ENV: &str = "/run/.containerenv";

/// Detect if the current environment is a container.
pub fn detect() -> bool {
    Path::new(CONTAINER_ENV).exists()
}

/// Run a command in a container environment.
pub fn run(_args: &[&str]) -> Result<(), CnfError> {
    Err(CnfError::NotImplemented("Environment Container".into()))
}