lux_cli/
download.rs

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