summaryrefslogtreecommitdiffstats
path: root/lib/App/Hiveminder/Command/Describe.pm
blob: 4f5a63ec846660de4613dfc9a387c0c413f412bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
package App::Hiveminder::Command::Describe;
use Moose;
use App::Hiveminder::Utils qw/get_text_from_editor_or_cmdline update_tasks
                              display_tasks/;
extends 'App::Hiveminder::Command';

=head2 NAME

App::Hiveminder::Command::Describe - Add a description to a task

=cut

sub command_names { qw/describe add-description add_description/ }

sub command {
    my $self = shift;

    return unless @_ > 1;
    my $task = $self->hm->read_task(shift);
    my $description = get_text_from_editor_or_cmdline(@_);
    chomp $description;
    $task = update_tasks($self->hm, [$hm->id2loc($task->{id})],
                         sub { (description => $description) })->[0];
    my $display = display_tasks($self->hm, $task);
    return "Description for $display:\n$task->{description}\n";
}

__PACKAGE__->meta()->make_immutable();
1;