diff options
Diffstat (limited to 'src/bin/summain.rs')
-rw-r--r-- | src/bin/summain.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/bin/summain.rs b/src/bin/summain.rs index 58d8788..9365243 100644 --- a/src/bin/summain.rs +++ b/src/bin/summain.rs @@ -1,12 +1,17 @@ use anyhow::Context; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use structopt::StructOpt; use summain::ManifestEntry; +use walkdir::WalkDir; #[tokio::main] async fn main() -> anyhow::Result<()> { - let mut opt = Opt::from_args(); - opt.pathnames[..].sort(); + let opt = Opt::from_args(); + let mut files = vec![]; + for pathname in opt.pathnames { + find(&pathname, &mut files)?; + } + files.sort(); // Get metadata about all files, but don't compute checksum yet. // @@ -18,7 +23,7 @@ async fn main() -> anyhow::Result<()> { // large: Linux only allows 128 KiB of command line arguments. let mut handles = vec![]; - for filename in opt.pathnames.iter().cloned() { + for filename in files.iter().cloned() { handles.push(tokio::spawn(async move { manifest(filename).await })); } @@ -49,6 +54,13 @@ async fn main() -> anyhow::Result<()> { Ok(()) } +fn find(root: &Path, files: &mut Vec<PathBuf>) -> anyhow::Result<()> { + for e in WalkDir::new(root) { + files.push(e?.path().to_path_buf()); + } + Ok(()) +} + #[derive(StructOpt, Debug)] struct Opt { #[structopt(parse(from_os_str))] |