Skip to main content

ferrum_cli/commands/
pull.rs

1//! Pull command - Download a model from HuggingFace Hub
2
3use crate::config::CliConfig;
4use clap::Args;
5use colored::*;
6use ferrum_types::Result;
7
8#[derive(Args)]
9pub struct PullCommand {
10    /// Model to download (for example `qwen3.5:4b-q4_k_m` on Metal or `qwen3.5:4b` on CUDA)
11    pub model: String,
12}
13
14pub async fn execute(cmd: PullCommand, config: CliConfig) -> Result<()> {
15    let cache_dir = crate::source_resolver::hf_cache_dir(&config);
16    println!(
17        "{} {}",
18        "Pulling".cyan().bold(),
19        crate::source_resolver::resolve_model_alias(&cmd.model)
20    );
21    println!("{}", format!("Cache: {}", cache_dir.display()).dimmed());
22
23    match crate::source_resolver::resolve_model_source(
24        &cmd.model,
25        &cache_dir,
26        crate::source_resolver::DownloadPolicy::AutoDownload,
27        None,
28    )
29    .await
30    {
31        Ok(resolved) => {
32            println!();
33            println!("{} Model ready at:", "✓".green().bold());
34            println!("  {}", resolved.local_path().display());
35            Ok(())
36        }
37        Err(error) => {
38            eprintln!();
39            eprintln!("{} Failed to pull model: {}", "✗".red().bold(), error);
40            eprintln!("Set HF_TOKEN for private models and verify network/proxy settings.");
41            Err(error)
42        }
43    }
44}