summaryrefslogtreecommitdiffstats
path: root/lib/App/Hiveminder/Command.pm
blob: 8647d357c2486ed4fd71cf548d3200dd3804c5c0 (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;
use Moose;
use Net::Hiveminder;
extends 'MooseX::App::Cmd::Command';

has _hm => (
    isa     => 'Net::Hiveminder',
    is      => 'ro',
    default => sub { Net::Hiveminder->new(use_config => 1) },
    reader  => 'hm',
);

sub run {
    my ($self, $opt, $args) = @_;

    my $result = $self->command($args);

    if (defined $result) {
        chomp $result;
        $result .= "\n" if length $result > 0;
        print $result;
    }
    else {
        die $self->usage->text;
    }
}

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