zoi-cli 1.24.2

Advanced Package Manager & Environment Orchestrator
Documentation
use crate::cli::SetupScope;
use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

#[derive(Parser, Debug)]
pub struct InstallCommand {
    /// Path to the package archive file (e.g. path/to/name-os-arch.zpa)
    #[arg(required = true)]
    pub package_file: PathBuf,
    /// The sub-packages to install from the archive.
    #[arg(long, short, num_args = 1..)]
    pub sub: Option<Vec<String>>,
    /// The scope to install the package to (user or system-wide)
    #[arg(long, value_enum, default_value_t = SetupScope::User)]
    pub scope: SetupScope,
    /// Automatically answer yes to all prompts
    #[arg(long)]
    pub yes: bool,
}

pub fn run(args: InstallCommand) -> Result<()> {
    let scope = match args.scope {
        SetupScope::User => crate::pkg::types::Scope::User,
        SetupScope::System => crate::pkg::types::Scope::System,
    };
    crate::pkg::install::pkg_install::run(
        &args.package_file,
        Some(scope),
        "local",
        None,
        args.yes,
        args.sub,
        true,
        None,
    )?;
    Ok(())
}