Skip to main content

zoi_cli/cmd/install/
mod.rs

1/// Command-line arguments for the `install` command.
2pub mod args;
3/// High-level installation orchestration.
4pub mod orchestrator;
5
6use anyhow::Result;
7use zoi_project as project;
8
9use crate::pkg::types;
10
11/// The primary high-level orchestration for the `zoi install` command.
12///
13/// # Errors
14///
15/// Returns an error if the installation process fails.
16pub fn run(
17    sources: &[String],
18    repo: Option<String>,
19    force: bool,
20    all_optional: bool,
21    yes: bool,
22    scope: Option<crate::cli::InstallScope>,
23    local: bool,
24    global: bool,
25    save: bool,
26    build_type: Option<&str>,
27    dry_run: bool,
28    plugin_manager: Option<&crate::pkg::plugin::PluginManager>,
29    build: bool,
30    frozen: bool,
31    explain: bool,
32    plan_json: bool,
33    retry: u32,
34    verbose: bool,
35    purl: bool,
36    project_config: Option<project::config::ProjectConfig>
37) -> Result<()> {
38    let mut resolved_scope = scope.map(|s| match s {
39        crate::cli::InstallScope::User => types::Scope::User,
40        crate::cli::InstallScope::System => types::Scope::System,
41        crate::cli::InstallScope::Project => types::Scope::Project
42    });
43
44    if local {
45        resolved_scope = Some(types::Scope::Project);
46    } else if global {
47        resolved_scope = Some(types::Scope::User);
48    }
49
50    let scope = resolved_scope
51        .unwrap_or_else(crate::pkg::utils::resolve_fallback_scope);
52
53    let options = orchestrator::InstallOptions {
54        scope,
55        force,
56        all_optional,
57        yes,
58        save,
59        build_type,
60        dry_run,
61        plugin_manager,
62        build,
63        frozen,
64        explain,
65        plan_json,
66        retry,
67        verbose,
68        purl,
69        project_config
70    };
71
72    let orchestrator = orchestrator::Orchestrator::new(options);
73    orchestrator.run(sources, repo)
74}