diff --git a/src/bin/cmd/bundle/extract.rs b/src/bin/cmd/bundle/extract.rs index ea30355..6bb6113 100644 --- a/src/bin/cmd/bundle/extract.rs +++ b/src/bin/cmd/bundle/extract.rs @@ -11,6 +11,8 @@ use futures::future::try_join_all; use glob::Pattern; use tokio::{fs, sync::RwLock}; +use crate::cmd::util::collect_bundle_paths; + fn parse_glob_pattern(s: &str) -> Result { match Pattern::new(s) { Ok(p) => Ok(p), @@ -148,7 +150,13 @@ pub(crate) async fn run(ctx: Arc>, matches: &ArgMatches) - .unwrap_or_default() .cloned(); - let bundles = try_join_all(bundles.into_iter().map(|p| async { + let paths = collect_bundle_paths(bundles).await; + + if paths.is_empty() { + return Err(eyre::eyre!("No bundle provided")); + } + + let bundles = try_join_all(paths.into_iter().map(|p| async { let ctx = ctx.clone(); let path_display = p.display().to_string(); async move { Bundle::open(ctx, &p).await } diff --git a/src/bin/cmd/bundle/list.rs b/src/bin/cmd/bundle/list.rs index b5dca5d..dd4345f 100644 --- a/src/bin/cmd/bundle/list.rs +++ b/src/bin/cmd/bundle/list.rs @@ -8,6 +8,8 @@ use dtmt::Bundle; use futures::future::try_join_all; use tokio::sync::RwLock; +use crate::cmd::util::collect_bundle_paths; + pub(crate) fn command_definition() -> Command { Command::new("list") .about("List the contents of one or multiple bundles.") @@ -36,7 +38,13 @@ pub(crate) async fn run(ctx: Arc>, matches: &ArgMatches) - .unwrap_or_default() .cloned(); - let bundles = try_join_all(bundles.into_iter().map(|p| async { + let paths = collect_bundle_paths(bundles).await; + + if paths.is_empty() { + return Err(eyre::eyre!("No bundle provided")); + } + + let bundles = try_join_all(paths.into_iter().map(|p| async { let ctx = ctx.clone(); let path_display = p.display().to_string(); async move { Bundle::open(ctx, &p).await }