1use anyhow::{Context, Result};
5use robonix_cli::output;
6use robonix_cli::{Config, install::PackageInstaller};
7use std::path::PathBuf;
8
9pub async fn execute(config: Config, github: Option<String>, path: Option<PathBuf>) -> Result<()> {
10 let installer = PackageInstaller::new(config.clone());
11 config.ensure_storage_dir()?;
12
13 if let Some(repo) = github {
14 output::action("Installing", &format!("from GitHub: {}", repo));
15 let branch = None::<&str>;
16 let name = installer.install_from_github(&repo, branch)?;
17 output::success(&format!("Installed '{}'", name));
18 return Ok(());
19 }
20
21 if let Some(p) = path {
22 let canonical = p
23 .canonicalize()
24 .with_context(|| format!("Failed to canonicalize: {}", p.display()))?;
25 output::action("Installing", &format!("from path: {}", canonical.display()));
26 let name = installer.install_from_path(&canonical)?;
27 output::success(&format!("Installed '{}'", name));
28 return Ok(());
29 }
30
31 anyhow::bail!("Specify --github <repo> or --path <dir> to install")
32}