App-karr
view release on metacpan or search on metacpan
lib/App/karr/Cmd/Handoff.pm view on Meta::CPAN
# ABSTRACT: Hand off a task for review
package App::karr::Cmd::Handoff;
our $VERSION = '0.102';
use Moo;
use MooX::Cmd;
use MooX::Options (
usage_string => 'USAGE: karr handoff ID --claim NAME [--note TEXT] [--block REASON] [--release]',
);
use App::karr::Role::BoardAccess;
use App::karr::Role::Output;
use App::karr::Task;
use App::karr::Config;
use Time::Piece;
with 'App::karr::Role::BoardAccess', 'App::karr::Role::Output', 'App::karr::Role::ClaimTimeout';
option claim => (
is => 'ro',
format => 's',
required => 1,
doc => 'Agent name claiming the task',
);
option note => (
is => 'ro',
format => 's',
doc => 'Handoff note to append to body',
);
option timestamp => (
is => 'ro',
short => 't',
doc => 'Prefix timestamp to note',
);
option block => (
is => 'ro',
format => 's',
doc => 'Block task with reason',
);
option release => (
is => 'ro',
doc => 'Release claim after handoff',
);
sub execute {
my ($self, $args_ref, $chain_ref) = @_;
$self->sync_before;
my $id = $args_ref->[0] or die "Usage: karr handoff ID --claim NAME [--note TEXT] [--block REASON] [--release]\n";
my $config = App::karr::Config->new(
file => $self->board_dir->child('config.yml'),
);
my $task = $self->find_task($id);
die "Task $id not found\n" unless $task;
# Validate claim ownership
if ($task->has_claimed_by && $task->claimed_by ne $self->claim) {
my $timeout = $self->_parse_timeout($config->claim_timeout);
unless ($self->_claim_expired($task, $timeout)) {
die sprintf "Task %d is claimed by %s\n", $task->id, $task->claimed_by;
}
}
# Move to review
my $old_status = $task->status;
if ($task->status ne 'review') {
$task->status('review');
}
( run in 2.833 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )