From f20bf09292739e1bdbba9c1f8235a35f7d2d7712 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 18 Jun 2021 08:41:19 +0200 Subject: Make progress bar for loading DAG optional Signed-off-by: Matthias Beyer --- src/commands/build.rs | 2 +- src/commands/tree_of.rs | 2 +- src/package/dag.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commands/build.rs b/src/commands/build.rs index 8825750..ff2769d 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -226,7 +226,7 @@ pub async fn build( let dag = { let bar_tree_building = progressbars.bar(); - let dag = Dag::for_root_package(package.clone(), &repo, &bar_tree_building)?; + let dag = Dag::for_root_package(package.clone(), &repo, Some(&bar_tree_building))?; bar_tree_building.finish_with_message("Finished loading Dag"); dag }; diff --git a/src/commands/tree_of.rs b/src/commands/tree_of.rs index e632ed5..a2ae0c5 100644 --- a/src/commands/tree_of.rs +++ b/src/commands/tree_of.rs @@ -48,7 +48,7 @@ pub async fn tree_of( }) .map(|package| { let bar_tree_building = progressbars.bar(); - let tree = Dag::for_root_package(package.clone(), &repo, &bar_tree_building)?; + let tree = Dag::for_root_package(package.clone(), &repo, Some(&bar_tree_building))?; bar_tree_building.finish_with_message("Finished loading Tree"); Ok(tree) }) diff --git a/src/package/dag.rs b/src/package/dag.rs index 1075dda..102355a 100644 --- a/src/package/dag.rs +++ b/src/package/dag.rs @@ -40,14 +40,14 @@ impl Dag { pub fn for_root_package( p: Package, repo: &Repository, - progress: &ProgressBar, + progress: Option<&ProgressBar>, ) -> Result { fn add_sub_packages<'a>( repo: &'a Repository, mappings: &mut HashMap<&'a Package, daggy::NodeIndex>, dag: &mut daggy::Dag<&'a Package, i8>, p: &'a Package, - progress: &ProgressBar + progress: Option<&ProgressBar> ) -> Result<()> { p.get_self_packaged_dependencies() .and_then_ok(|(name, constr)| { @@ -63,7 +63,7 @@ impl Dag { // recurse packs.into_iter() .try_for_each(|p| { - progress.tick(); + progress.as_ref().map(|p| p.tick()); let idx = dag.add_node(p); mappings.insert(p, idx); -- cgit v1.2.3 From b140c12b53931bf463f706d28ddb3be0c0fb0e4f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 18 Jun 2021 08:42:46 +0200 Subject: Remove progressbar for tree-of subcommand Remove the progress bar here because it does not bring any real value and rather clutters the output and thus makes it harder to read. Signed-off-by: Matthias Beyer Tested-by: Matthias Beyer --- src/commands/tree_of.rs | 9 +-------- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/commands/tree_of.rs b/src/commands/tree_of.rs index a2ae0c5..b816d24 100644 --- a/src/commands/tree_of.rs +++ b/src/commands/tree_of.rs @@ -21,13 +21,11 @@ use crate::package::PackageName; use crate::package::PackageVersionConstraint; use crate::package::Dag; use crate::repository::Repository; -use crate::util::progress::ProgressBars; /// Implementation of the "tree_of" subcommand pub async fn tree_of( matches: &ArgMatches, repo: Repository, - progressbars: ProgressBars, ) -> Result<()> { let pname = matches .value_of("package_name") @@ -46,12 +44,7 @@ pub async fn tree_of( .map(|v| v.matches(p.version())) .unwrap_or(true) }) - .map(|package| { - let bar_tree_building = progressbars.bar(); - let tree = Dag::for_root_package(package.clone(), &repo, Some(&bar_tree_building))?; - bar_tree_building.finish_with_message("Finished loading Tree"); - Ok(tree) - }) + .map(|package| Dag::for_root_package(package.clone(), &repo, None)) .and_then_ok(|tree| { let stdout = std::io::stdout(); let mut outlock = stdout.lock(); diff --git a/src/main.rs b/src/main.rs index 59dd559..5ae443b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -234,7 +234,7 @@ async fn main() -> Result<()> { Some(("tree-of", matches)) => { let repo = load_repo()?; - crate::commands::tree_of(matches, repo, progressbars) + crate::commands::tree_of(matches, repo) .await .context("tree-of command failed")? } -- cgit v1.2.3