use console::style;
use std::path::PathBuf;
use trauma::{
download::Download,
downloader::{DownloaderBuilder, ProgressBarOpts, StyleOptions},
Error,
};
#[tokio::main]
async fn main() -> Result<(), Error> {
let debian_net_install =
"https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-11.7.0-arm64-netinst.iso";
let downloads = vec![Download::try_from(debian_net_install).unwrap()];
let style_opts = StyleOptions::new(
ProgressBarOpts::new(
Some(ProgressBarOpts::TEMPLATE_BAR_WITH_POSITION.into()),
Some(ProgressBarOpts::CHARS_FINE.into()),
true,
false,
),
ProgressBarOpts::new(
Some(format!(
"{{bar:40.cyan/blue}} {{percent:>2.magenta}}{} ● {{eta_precise:.blue}}",
style("%").magenta(),
)),
Some("●◕◑◔○".into()),
true,
false,
),
);
let downloader = DownloaderBuilder::new()
.directory(PathBuf::from("output"))
.style_options(style_opts)
.build();
downloader.download(&downloads).await;
Ok(())
}