diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-11-12 14:21:26 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-11-12 17:02:58 +0300 |
commit | 5b2f02086f9295cf16e19cb3b7e5369b313bb422 (patch) | |
tree | d53b87ffbb7eadfa258f9d9891363306110d6f98 /bpkg/pkg-command.cxx | |
parent | e87d381eab6233f9493e7e0e96b3a5a6944cedce (diff) |
Add --all-pattern option to pkg-{update,clean,test,install,uninstall} commands
Diffstat (limited to 'bpkg/pkg-command.cxx')
-rw-r--r-- | bpkg/pkg-command.cxx | 29 |
1 files changed, 26 insertions, 3 deletions
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 <bpkg/pkg-command.hxx> +#include <libbutl/path-pattern.mxx> + #include <bpkg/package.hxx> #include <bpkg/package-odb.hxx> #include <bpkg/database.hxx> @@ -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<selected_package>; @@ -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 ()) |