zoi_common/lib.rs
1//! Common types and utilities for the Zoi package manager.
2//!
3//! This crate provides shared data structures, traits, and user experience (UX)
4//! components that are used across multiple Zoi crates, including the main
5//! CLI and Zoi Mini.
6
7use anyhow::Result;
8use zoi_core::types::Scope;
9
10/// User experience data structures and utilities.
11pub mod ux;
12
13/// Options for installing packages from source.
14#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Default)]
15pub struct SourceInstallOptions {
16 /// The repository to install from.
17 pub repo: Option<String>,
18 /// Whether to force the installation.
19 pub force: bool,
20 /// Whether to install all optional dependencies.
21 pub all_optional: bool,
22 /// Whether to skip confirmation prompts.
23 pub yes: bool,
24 /// Override the installation scope.
25 pub scope_override: Option<Scope>,
26 /// Whether to save the installation to the project file.
27 pub save: bool,
28 /// The build type to use.
29 pub build_type: Option<String>,
30 /// Whether to perform a dry run.
31 pub dry_run: bool,
32 /// Whether to build the package.
33 pub build: bool,
34 /// Whether to use the lockfile exactly (frozen).
35 pub frozen: bool
36}
37
38/// A trait for subcommands that can be executed.
39pub trait Runnable {
40 /// Executes the subcommand.
41 ///
42 /// # Errors
43 ///
44 /// Returns an error if the command execution fails.
45 fn run(&self, yes: bool) -> Result<()>;
46}