diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-23 11:49:46 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-23 11:49:46 +0300 |
commit | ae8d02b35d8809ebba69231418fb411c47dda946 (patch) | |
tree | 18b058568d89744bf1abfe8a63a2762c3843a66d | |
parent | a8f7ef51d53adc9a47ad0a6ff871d943ffb48039 (diff) | |
download | summain-rs-ae8d02b35d8809ebba69231418fb411c47dda946.tar.gz |
only print after everything is computede
-rw-r--r-- | src/bin/summain.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/bin/summain.rs b/src/bin/summain.rs index 66e9f9f..22d32c6 100644 --- a/src/bin/summain.rs +++ b/src/bin/summain.rs @@ -1,5 +1,5 @@ use anyhow::Context; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use structopt::StructOpt; use summain::ManifestEntry; @@ -18,11 +18,12 @@ async fn async_main() -> anyhow::Result<()> { let mut handles = vec![]; for filename in opt.pathnames.iter().cloned() { - handles.push(tokio::spawn(async move { report(filename) })); + handles.push(tokio::spawn(async move { manifest(filename) })); } for h in handles { - h.await?.await?; + let m = h.await?.await?; + print!("{}", serde_yaml::to_string(&m)?); } Ok(()) @@ -34,14 +35,8 @@ struct Opt { pathnames: Vec<PathBuf>, } -async fn report(path: PathBuf) -> anyhow::Result<()> { - let m = manifest(&path).await?; - print!("{}", serde_yaml::to_string(&m)?); - Ok(()) -} - -async fn manifest(path: &Path) -> anyhow::Result<ManifestEntry> { - ManifestEntry::new(path) +async fn manifest(path: PathBuf) -> anyhow::Result<ManifestEntry> { + ManifestEntry::new(&path) .await .with_context(|| format!("{}", path.display())) } |