1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// 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>
//! # cnf-lib - Library code for `cnf`
//!
//! The code contained here serves three main purposes.
//!
//!
//! ## Handling environments
//!
//! An "environment" is anything that offers one or more "providers" (see below). All supported
//! environments are listed in the [`Environment`] enum.
//!
//! It is often desirable to temporarily escape one environment for the sake of executing a single
//! command. There are usually controlled mechanisms to perform this task. This crate aims to
//! transparently manage the command translation necessary in order to, for example, execute `htop`
//! inside a Toolbx container while working on the host. All of this is implemented in the
//! [`Environment`] type and [`IsEnvironment`] trait.
//!
//! Take a look at the documentation and code in [`environment`] if you want to know more about this
//! command translation.
//!
//!
//! ## Handling providers
//!
//! A "provider" is anything that offers executable software. This includes for example the system
//! `$PATH` (where executables are usually located and can be executed immediately), but extends to
//! regular package managers such as `dnf`, usually requiring installation of commands before they
//! can be executed. All supported providers are listed in the [`Provider`] enum.
//!
//! Providers can be searched for a command and return a list of zero or more possible candidates
//! matching the search term. All of this is implemented in the [`Provider`] type and [`IsProvider`]
//! trait.
//!
//! Take a look at the documentation and code in [`provider`] if you want to know more about this
//! and for detailed instructions about implementing new providers.
//!
//!
//! ## Handling command invocations
//!
//! Translating regular command lines between environments has a few pitfalls with respect to e.g.
//! privilege escalation and correctly reading stdout/stderr. The [`CommandLine`] type provides the
//! necessary abstractions to allow seamless command execution without having to wonder how
//! privilege escalation in the target environment works, for example.
// Quicker access to modules
pub use environment as env;
pub use provider as prov;
pub use ;
pub use ;
pub use CommandLine;
/// Public prelude.