From 5b2f02086f9295cf16e19cb3b7e5369b313bb422 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 12 Nov 2020 14:21:26 +0300 Subject: Add --all-pattern option to pkg-{update,clean,test,install,uninstall} commands --- bpkg/pkg-command.cxx | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'bpkg/pkg-command.cxx') diff --git a/bpkg/pkg-command.cxx b/bpkg/pkg-command.cxx index 0828118..11f10f0 100644 --- a/bpkg/pkg-command.cxx +++ b/bpkg/pkg-command.cxx @@ -3,6 +3,8 @@ #include +#include + #include #include #include @@ -150,6 +152,7 @@ namespace bpkg bool recursive, bool immediate, bool all, + const strings& all_patterns, bool package_cwd, cli::group_scanner& args) { @@ -216,7 +219,7 @@ namespace bpkg // Check that options and arguments are consistent. // // Note that we can as well count on the option names that correspond to - // the immediate, recursive, and all parameters. + // the immediate, recursive, all, and all_patterns parameters. // { diag_record dr; @@ -225,9 +228,17 @@ namespace bpkg dr << fail << "both --immediate|-i and --recursive|-r specified"; else if (all) { + if (!all_patterns.empty ()) + dr << fail << "both --all|-a and --all-pattern specified"; + if (!pkg_args.empty ()) dr << fail << "both --all|-a and package argument specified"; } + else if (!all_patterns.empty ()) + { + if (!pkg_args.empty ()) + dr << fail << "both --all-pattern and package argument specified"; + } else if (pkg_args.empty ()) dr << fail << "package name argument expected"; @@ -257,7 +268,7 @@ namespace bpkg collect_dependencies (p, recursive, package_cwd, ps); }; - if (all) + if (all || !all_patterns.empty ()) { using query = query; @@ -270,7 +281,19 @@ namespace bpkg { l4 ([&]{trace << *p;}); - add (p, strings ()); + if (!all_patterns.empty ()) + { + for (const string& pat: all_patterns) + { + if (path_match (p->name.string (), pat)) + { + add (p, strings ()); + break; + } + } + } + else // --all + add (p, strings ()); } if (ps.empty ()) -- cgit v1.1