# --allow-blessed=BLESSING,... default is from `prepare'
# --allow-job-status=STATUS,... default is only `pass'
#
-# ./mg-anoint retrieve REFKEY
+# ./mg-anoint retrieve [--tolerate-unprepared] REFKEY
# => FLIGHT JOB
# if nothing anointed yet, prints nothing and exits 0
# if anointment not prepared, fails
+# With --tolerate-unprepared, it is not an error if nothing is
+# reported because the anointment has not been prepared.
#
# ./mg-anoint list-prepared REFKEY-GLOB
# => possibly empty list of REFKEYs
}
sub cmd_retrieve {
+ my $tolerate_unprepared;
+ if (@ARGV && $ARGV[0] eq '--tolerate-unprepared') {
+ shift @ARGV;
+ $tolerate_unprepared = 1;
+ }
die unless @ARGV==1;
die if $ARGV[0] =~ m/^-/;
my ($refkey) = @ARGV;
@o = ();
$task_q->execute($refkey);
my ($task) = $task_q->fetchrow_array();
- die "no such anointment kind \`$refkey'" unless defined $task;
+ die "no such anointment kind \`$refkey'"
+ unless defined $task or $tolerate_unprepared;
$mostrecent_q->execute($task);
my $row = $mostrecent_q->fetchrow_hashref();