Skip to main content

lux_cli/
download.rs

1use clap::Args;
2use eyre::Result;
3use lux_lib::{config::Config, operations, package::PackageReq, progress::MultiProgress};
4
5#[derive(Args)]
6pub struct Download {
7    package_req: PackageReq,
8}
9
10pub async fn download(dl_data: Download, config: Config) -> Result<()> {
11    let progress = MultiProgress::new(&config);
12    let bar = progress.map(MultiProgress::new_bar);
13
14    let rock = operations::Download::new(&dl_data.package_req, &config, &bar)
15        .download_src_rock_to_file(None)
16        .await?;
17
18    bar.map(|b| {
19        b.finish_with_message(format!(
20            "Succesfully downloaded {}@{}",
21            rock.name, rock.version
22        ))
23    });
24
25    Ok(())
26}