feat: display packages in progress bars

This commit is contained in:
daimond113 2024-11-10 18:08:59 +01:00
parent f7808e452d
commit 1369fe990b
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
5 changed files with 24 additions and 14 deletions

View file

@ -211,8 +211,9 @@ impl InstallCommand {
graph.values().map(|versions| versions.len() as u64).sum(),
rx,
&multi,
format!("{} 📥 downloading dependencies", job(3)),
format!("{} 📥 downloaded dependencies", job(3)),
format!("{} 📥 ", job(3)),
"downloading dependencies".to_string(),
"downloaded dependencies".to_string(),
)
.await?;
@ -250,8 +251,9 @@ impl InstallCommand {
manifest.patches.values().map(|v| v.len() as u64).sum(),
rx,
&multi,
format!("{} 🩹 applying patches", job(4)),
format!("{} 🩹 applied patches", job(4)),
format!("{} 🩹 ", job(4)),
"applying patches".to_string(),
"applied patches".to_string(),
)
.await?;
}

View file

@ -54,8 +54,9 @@ impl UpdateCommand {
graph.values().map(|versions| versions.len() as u64).sum(),
rx,
&multi,
"📥 downloading dependencies".to_string(),
"📥 downloaded dependencies".to_string(),
"📥 ".to_string(),
"downloading dependencies".to_string(),
"downloaded dependencies".to_string(),
)
.await?;

View file

@ -192,8 +192,9 @@ pub fn parse_gix_url(s: &str) -> Result<gix::Url, gix::url::parse::Error> {
pub async fn progress_bar<E: std::error::Error + Into<anyhow::Error>>(
len: u64,
mut rx: tokio::sync::mpsc::Receiver<Result<(), E>>,
mut rx: tokio::sync::mpsc::Receiver<Result<String, E>>,
multi: &MultiProgress,
prefix: String,
progress_msg: String,
finish_msg: String,
) -> anyhow::Result<()> {
@ -201,8 +202,10 @@ pub async fn progress_bar<E: std::error::Error + Into<anyhow::Error>>(
indicatif::ProgressBar::new(len)
.with_style(
indicatif::ProgressStyle::default_bar()
.template("{msg} {bar:40.208/166} {pos}/{len} {percent}% {elapsed_precise}")?,
.template("{prefix}[{elapsed_precise}] {bar:40.208/166} {pos}/{len} {msg}")?
.progress_chars("█▓▒░ "),
)
.with_prefix(prefix)
.with_message(progress_msg),
);
bar.enable_steady_tick(Duration::from_millis(100));
@ -211,7 +214,9 @@ pub async fn progress_bar<E: std::error::Error + Into<anyhow::Error>>(
bar.inc(1);
match result {
Ok(()) => {}
Ok(text) => {
bar.set_message(text);
}
Err(e) => return Err(e.into()),
}
}

View file

@ -17,7 +17,7 @@ use std::{
type MultithreadedGraph = Arc<Mutex<DownloadedGraph>>;
type MultithreadDownloadJob = (
tokio::sync::mpsc::Receiver<Result<(), errors::DownloadGraphError>>,
tokio::sync::mpsc::Receiver<Result<String, errors::DownloadGraphError>>,
MultithreadedGraph,
);
@ -119,6 +119,8 @@ impl Project {
}
}
let display_name = format!("{name}@{version_id}");
{
let mut downloaded_graph = downloaded_graph.lock().unwrap();
downloaded_graph
@ -127,7 +129,7 @@ impl Project {
.insert(version_id, DownloadedDependencyGraphNode { node, target });
}
tx.send(Ok(())).await.unwrap();
tx.send(Ok(display_name)).await.unwrap();
});
}
}

View file

@ -76,7 +76,7 @@ impl Project {
&self,
graph: &DownloadedGraph,
) -> Result<
tokio::sync::mpsc::Receiver<Result<(), errors::ApplyPatchesError>>,
tokio::sync::mpsc::Receiver<Result<String, errors::ApplyPatchesError>>,
errors::ApplyPatchesError,
> {
let manifest = self.deser_manifest().await?;
@ -103,7 +103,7 @@ impl Project {
log::warn!(
"patch for {name}@{version_id} not applied because it is not in the graph"
);
tx.send(Ok(())).await.unwrap();
tx.send(Ok(format!("{name}@{version_id}"))).await.unwrap();
continue;
};
@ -212,7 +212,7 @@ impl Project {
return;
}
tx.send(Ok(())).await.unwrap();
tx.send(Ok(format!("{name}@{version_id}"))).await.unwrap();
});
}
}