@@ -20,6 +20,9 @@
# if nothing anointed yet, prints nothing and exits 0
# if anointment not prepared, fails
#
+# ./mg-anoint list-prepared REFKEY-GLOB
+# => possibly empty list of REFKEYs
+#
# ./mg-anoint list
# => human-readable output
@@ -65,6 +68,7 @@ use Osstest;
use Osstest::TestSupport;
use Osstest::Executive;
use IO::Handle;
+use Text::Glob qw(glob_to_regex);
csreadconfig();
@@ -337,6 +341,31 @@ END
pr_o();
}
+sub cmd_list_prepared {
+ die unless @ARGV==1;
+ die if $ARGV[0] =~ m/^-/;
+ my ($pat) = @ARGV;
+ my $re = glob_to_regex $pat;
+
+ my $tq = $dbh_tests->prepare(<<END);
+ SELECT *
+ FROM tasks
+ WHERE type = 'anoint'
+ ORDER BY refkey
+END
+
+ db_retry($dbh_tests, [], sub {
+ @o = ();
+ db_readonly_report();
+ $tq->execute();
+ while (my $t = $tq->fetchrow_hashref()) {
+ next unless $t->{refkey} =~ m{$re}o;
+ push @o, $t->{refkey};
+ }
+ });
+ pr_o();
+}
+
die 'need operation' unless @ARGV;
die 'no global options understood' if $ARGV[0] =~ m/^-/;
CC: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- mg-anoint | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)