aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-11-12 14:21:26 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-12 17:02:58 +0300
commit5b2f02086f9295cf16e19cb3b7e5369b313bb422 (patch)
treed53b87ffbb7eadfa258f9d9891363306110d6f98
parente87d381eab6233f9493e7e0e96b3a5a6944cedce (diff)
Add --all-pattern option to pkg-{update,clean,test,install,uninstall} commands
-rw-r--r--bpkg/pkg-clean.cli23
-rw-r--r--bpkg/pkg-clean.hxx1
-rw-r--r--bpkg/pkg-command.cxx29
-rw-r--r--bpkg/pkg-command.hxx1
-rw-r--r--bpkg/pkg-install.cli27
-rw-r--r--bpkg/pkg-install.hxx1
-rw-r--r--bpkg/pkg-test.cli22
-rw-r--r--bpkg/pkg-test.hxx1
-rw-r--r--bpkg/pkg-uninstall.cli26
-rw-r--r--bpkg/pkg-uninstall.hxx1
-rw-r--r--bpkg/pkg-update.cli24
-rw-r--r--bpkg/pkg-update.hxx1
-rw-r--r--tests/pkg-test.testscript37
13 files changed, 156 insertions, 38 deletions
diff --git a/bpkg/pkg-clean.cli b/bpkg/pkg-clean.cli
index b4cb05f..d51736a 100644
--- a/bpkg/pkg-clean.cli
+++ b/bpkg/pkg-clean.cli
@@ -15,15 +15,18 @@ namespace bpkg
"\h|SYNOPSIS|
\c{\b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] <pkg>...\n
- \b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] \b{--all}|\b{-a}}
+ \b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] \b{--all}|\b{-a}\n
+ \b{bpkg pkg-clean}|\b{clean} [<options>] [<vars>] (\b{--all-pattern} <pattern>)...}
\h|DESCRIPTION|
- The \cb{pkg-clean} command cleans the specified packages (the first form)
- or all the held packages (the second form, see \l{bpkg-pkg-status(1)}).
- Underneath, this command doesn't do much more than run \cb{b clean}. In
- the first form the specified packages must have been previously
- configured with \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
+ The \cb{pkg-clean} command cleans the specified packages (the first
+ form), all the held packages (the second form, see
+ \l{bpkg-pkg-status(1)}), or all the held packages that match any of the
+ specified wildcard patterns (the third form). Underneath, this command
+ doesn't do much more than run \cb{b clean}. In the first form the
+ specified packages must have been previously configured with
+ \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system. Such variables apply to all the specified
@@ -40,6 +43,14 @@ namespace bpkg
{
"Clean all held packages."
}
+
+ strings --all-pattern
+ {
+ "<pattern>",
+ "Clean held packages that match the specified wildcard pattern. Repeat
+ this option to match multiple patterns. Note that you may need to
+ quote the pattern to prevent expansion by your shell."
+ }
};
"
diff --git a/bpkg/pkg-clean.hxx b/bpkg/pkg-clean.hxx
index d99cd2a..c7c722c 100644
--- a/bpkg/pkg-clean.hxx
+++ b/bpkg/pkg-clean.hxx
@@ -21,6 +21,7 @@ namespace bpkg
false /* recursive */,
false /* immediate */,
o.all (),
+ o.all_pattern (),
false /* package_cwd */,
args);
}
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 ())
diff --git a/bpkg/pkg-command.hxx b/bpkg/pkg-command.hxx
index 3196bb1..40a55f2 100644
--- a/bpkg/pkg-command.hxx
+++ b/bpkg/pkg-command.hxx
@@ -27,6 +27,7 @@ namespace bpkg
bool recursive,
bool immediate,
bool all,
+ const strings& all_patterns,
bool package_cwd,
cli::group_scanner& args);
diff --git a/bpkg/pkg-install.cli b/bpkg/pkg-install.cli
index 308945a..ed22e3a 100644
--- a/bpkg/pkg-install.cli
+++ b/bpkg/pkg-install.cli
@@ -15,18 +15,21 @@ namespace bpkg
"\h|SYNOPSIS|
\c{\b{bpkg pkg-install}|\b{install} [<options>] [<vars>] <pkg>...\n
- \b{bpkg pkg-install}|\b{install} [<options>] [<vars>] \b{--all}|\b{-a}}
+ \b{bpkg pkg-install}|\b{install} [<options>] [<vars>] \b{--all}|\b{-a}\n
+ \b{bpkg pkg-install}|\b{install} [<options>] [<vars>] (\b{--all-pattern} <pattern>)...}
\h|DESCRIPTION|
The \cb{pkg-install} command installs the specified packages (the first
- form) or all held packages (the second form, see \l{bpkg-pkg-status(1)}).
- Additionally, immediate or all dependencies of these packages can be also
- installed by specifying the \c{\b{--immediate}|\b{-i}} or
- \c{\b{--recursive}|\b{-r}} options, respectively. Underneath, this
- command doesn't do much more than run \cb{b install}. In the first form
- the specified packages must have been previously configured with
- \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
+ form), all the held packages (the second form, see
+ \l{bpkg-pkg-status(1)}), or all the held packages that match any of the
+ specified wildcard patterns (the third form). Additionally, immediate or
+ all dependencies of these packages can be also installed by specifying
+ the \c{\b{--immediate}|\b{-i}} or \c{\b{--recursive}|\b{-r}} options,
+ respectively. Underneath, this command doesn't do much more than run
+ \cb{b install}. In the first form the specified packages must have been
+ previously configured with \l{bpkg-pkg-build(1)} or
+ \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system. Such variables apply to all the specified
@@ -54,6 +57,14 @@ namespace bpkg
"Install all held packages."
}
+ strings --all-pattern
+ {
+ "<pattern>",
+ "Install held packages that match the specified wildcard pattern. Repeat
+ this option to match multiple patterns. Note that you may need to quote
+ the pattern to prevent expansion by your shell."
+ }
+
bool --immediate|-i
{
"Also install immediate dependencies."
diff --git a/bpkg/pkg-install.hxx b/bpkg/pkg-install.hxx
index 5c06690..120576a 100644
--- a/bpkg/pkg-install.hxx
+++ b/bpkg/pkg-install.hxx
@@ -22,6 +22,7 @@ namespace bpkg
o.recursive (),
o.immediate (),
o.all (),
+ o.all_pattern (),
false /* package_cwd */,
args);
}
diff --git a/bpkg/pkg-test.cli b/bpkg/pkg-test.cli
index d9fb787..e2c2965 100644
--- a/bpkg/pkg-test.cli
+++ b/bpkg/pkg-test.cli
@@ -15,15 +15,17 @@ namespace bpkg
"\h|SYNOPSIS|
\c{\b{bpkg pkg-test}|\b{test} [<options>] [<vars>] <pkg>...\n
- \b{bpkg pkg-test}|\b{test} [<options>] [<vars>] \b{--all}|\b{-a}}
+ \b{bpkg pkg-test}|\b{test} [<options>] [<vars>] \b{--all}|\b{-a}\n
+ \b{bpkg pkg-test}|\b{test} [<options>] [<vars>] (\b{--all-pattern} <pattern>)...}
\h|DESCRIPTION|
- The \cb{pkg-test} command tests the specified packages (the first form)
- or all the held packages (the second form, see \l{bpkg-pkg-status(1)}).
- Additionally, immediate or all dependencies of these packages can also be
- tested by specifying the \c{\b{--immediate}|\b{-i}} or
- \c{\b{--recursive}|\b{-r}} options, respectively. Underneath, this
+ The \cb{pkg-test} command tests the specified packages (the first form),
+ all the held packages (the second form, see \l{bpkg-pkg-status(1)}), or
+ all the held packages that match any of the specified wildcard patterns
+ (the third form). Additionally, immediate or all dependencies of these
+ packages can also be tested by specifying the \c{\b{--immediate}|\b{-i}}
+ or \c{\b{--recursive}|\b{-r}} options, respectively. Underneath, this
command doesn't do much more than run \cb{b test}. In the first form the
specified packages must have been previously configured with
\l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
@@ -44,6 +46,14 @@ namespace bpkg
"Test all held packages."
}
+ strings --all-pattern
+ {
+ "<pattern>",
+ "Test held packages that match the specified wildcard pattern. Repeat
+ this option to match multiple patterns. Note that you may need to quote
+ the pattern to prevent expansion by your shell."
+ }
+
bool --immediate|-i
{
"Also test immediate dependencies."
diff --git a/bpkg/pkg-test.hxx b/bpkg/pkg-test.hxx
index c9ec339..0cadabe 100644
--- a/bpkg/pkg-test.hxx
+++ b/bpkg/pkg-test.hxx
@@ -21,6 +21,7 @@ namespace bpkg
o.recursive (),
o.immediate (),
o.all (),
+ o.all_pattern (),
o.package_cwd (),
args);
}
diff --git a/bpkg/pkg-uninstall.cli b/bpkg/pkg-uninstall.cli
index 0e9d758..dead6d0 100644
--- a/bpkg/pkg-uninstall.cli
+++ b/bpkg/pkg-uninstall.cli
@@ -15,18 +15,20 @@ namespace bpkg
"\h|SYNOPSIS|
\c{\b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] <pkg>...\n
- \b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] \b{--all}|\b{-a}}
+ \b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] \b{--all}|\b{-a}\n
+ \b{bpkg pkg-uninstall}|\b{uninstall} [<options>] [<vars>] (\b{--all-pattern} <pattern>)...}
\h|DESCRIPTION|
The \cb{pkg-uninstall} command uninstalls the specified packages (the
- first form) or all held packages (the second form, see
- \l{bpkg-pkg-status(1)}). Additionally, immediate or all dependencies of
- these specified packages can be also uninstalled by specifying the
- \c{\b{--immediate}|\b{-i}} or \c{\b{--recursive}|\b{-r}} options,
- respectively. Underneath, this command doesn't do much more than run
- \cb{b uninstall}. In the first form the specified packages must have been
- previously configured with \l{bpkg-pkg-build(1)} or
+ first form), all the held packages (the second form, see
+ \l{bpkg-pkg-status(1)}), or all the held packages that match any of the
+ specified wildcard patterns (the third form). Additionally, immediate or
+ all dependencies of these specified packages can be also uninstalled by
+ specifying the \c{\b{--immediate}|\b{-i}} or \c{\b{--recursive}|\b{-r}}
+ options, respectively. Underneath, this command doesn't do much more than
+ run \cb{b uninstall}. In the first form the specified packages must have
+ been previously configured with \l{bpkg-pkg-build(1)} or
\l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
@@ -45,6 +47,14 @@ namespace bpkg
"Uninstall all held packages."
}
+ strings --all-pattern
+ {
+ "<pattern>",
+ "Uninstall held packages that match the specified wildcard pattern.
+ Repeat this option to match multiple patterns. Note that you may need
+ to quote the pattern to prevent expansion by your shell."
+ }
+
bool --immediate|-i
{
"Also uninstall immediate dependencies."
diff --git a/bpkg/pkg-uninstall.hxx b/bpkg/pkg-uninstall.hxx
index d3b6c63..94a8390 100644
--- a/bpkg/pkg-uninstall.hxx
+++ b/bpkg/pkg-uninstall.hxx
@@ -21,6 +21,7 @@ namespace bpkg
o.recursive (),
o.immediate (),
o.all (),
+ o.all_pattern (),
false /* package_cwd */,
args);
}
diff --git a/bpkg/pkg-update.cli b/bpkg/pkg-update.cli
index 531da4a..7887185 100644
--- a/bpkg/pkg-update.cli
+++ b/bpkg/pkg-update.cli
@@ -15,17 +15,19 @@ namespace bpkg
"\h|SYNOPSIS|
\c{\b{bpkg pkg-update}|\b{update} [<options>] [<vars>] <pkg>...\n
- \b{bpkg pkg-update}|\b{update} [<options>] [<vars>] \b{--all}|\b{-a}}
+ \b{bpkg pkg-update}|\b{update} [<options>] [<vars>] \b{--all}|\b{-a}\n
+ \b{bpkg pkg-update}|\b{update} [<options>] [<vars>] (\b{--all-pattern} <pattern>)...}
\h|DESCRIPTION|
The \cb{pkg-update} command updates the specified packages (the first
- form) or all the held packages (the second form, see
- \l{bpkg-pkg-status(1)}). Underneath, this command doesn't do much more
- than run \cb{b update} (or one of its \c{update-for-*} variants; see
- \cb{--for|-f}). In the first form the specified packages must have been
- previously configured with \l{bpkg-pkg-build(1)} or
- \l{bpkg-pkg-configure(1)}.
+ form), all the held packages (the second form, see
+ \l{bpkg-pkg-status(1)}), or all the held packages that match any of the
+ specified wildcard patterns (the third form). Underneath, this command
+ doesn't do much more than run \cb{b update} (or one of its
+ \c{update-for-*} variants; see \cb{--for|-f}). In the first form the
+ specified packages must have been previously configured with
+ \l{bpkg-pkg-build(1)} or \l{bpkg-pkg-configure(1)}.
Additional command line variables (<vars>, normally \cb{config.*}) can be
passed to the build system. Such variables apply to all the specified
@@ -43,6 +45,14 @@ namespace bpkg
"Update all held packages."
}
+ strings --all-pattern
+ {
+ "<pattern>",
+ "Update held packages that match the specified wildcard pattern. Repeat
+ this option to match multiple patterns. Note that you may need to quote
+ the pattern to prevent expansion by your shell."
+ }
+
string --for|-f
{
"<operation>",
diff --git a/bpkg/pkg-update.hxx b/bpkg/pkg-update.hxx
index 7eb4c37..72d8cd5 100644
--- a/bpkg/pkg-update.hxx
+++ b/bpkg/pkg-update.hxx
@@ -22,6 +22,7 @@ namespace bpkg
false /* recursive */,
false /* immediate */,
o.all (),
+ o.all_pattern (),
false /* package_cwd */,
args);
}
diff --git a/tests/pkg-test.testscript b/tests/pkg-test.testscript
index 5e212f4..c8b4a8e 100644
--- a/tests/pkg-test.testscript
+++ b/tests/pkg-test.testscript
@@ -42,6 +42,13 @@ test.options += --build-option -s
info: run 'bpkg help pkg-test' for more information
EOE
+ : all-all-pattern
+ :
+ $* --all --all-pattern 'lib*' 2>>EOE != 0
+ error: both --all|-a and --all-pattern specified
+ info: run 'bpkg help pkg-test' for more information
+ EOE
+
: all-name
:
$* --all libbaz 2>>EOE != 0
@@ -49,6 +56,13 @@ test.options += --build-option -s
info: run 'bpkg help pkg-test' for more information
EOE
+ : all-pattern-name
+ :
+ $* --all-pattern 'lib*' libbaz 2>>EOE != 0
+ error: both --all-pattern and package argument specified
+ info: run 'bpkg help pkg-test' for more information
+ EOE
+
: recursive-immediate
:
$* libbaz --recursive --immediate 2>>~%EOE% != 0
@@ -92,6 +106,29 @@ test.options += --build-option -s
}
}
+: all-pattern
+:
+{
+ : match
+ :
+ {
+ $clone_root_cfg;
+
+ $* --all-pattern 'libf*' --all-pattern 'lib*' --all-pattern 'libz*' 2>>~%EOE%
+ %info: .+ has nothing to test%
+ tested libbaz/0.0.3
+ EOE
+ }
+
+ : not-match
+ :
+ {
+ $clone_root_cfg;
+
+ $* --all-pattern 'libf*' 2>'info: nothing to test'
+ }
+}
+
: immediate
:
{