summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-05-08 22:22:20 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-05-08 22:22:20 -0500
commitfab92c20d706c67f3f95dcf0a92caaf9533ddc22 (patch)
treee7d785b6699ea43c295c9e27b29f7489fd5b3405
parentd40712ec2d754d09dd9718a4875cb1a605139af7 (diff)
downloadapp-hiveminder-fab92c20d706c67f3f95dcf0a92caaf9533ddc22.tar.gz
app-hiveminder-fab92c20d706c67f3f95dcf0a92caaf9533ddc22.zip
move more work into the command base class
-rw-r--r--lib/App/Hiveminder/Command.pm15
-rw-r--r--lib/App/Hiveminder/Command/create.pm6
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/App/Hiveminder/Command.pm b/lib/App/Hiveminder/Command.pm
index a85f6d0..fd58ab7 100644
--- a/lib/App/Hiveminder/Command.pm
+++ b/lib/App/Hiveminder/Command.pm
@@ -10,5 +10,20 @@ has hm => (
default => sub { Net::Hiveminder->new(use_config => 1) },
);
+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;
diff --git a/lib/App/Hiveminder/Command/create.pm b/lib/App/Hiveminder/Command/create.pm
index 7143ba0..e99fb24 100644
--- a/lib/App/Hiveminder/Command/create.pm
+++ b/lib/App/Hiveminder/Command/create.pm
@@ -5,8 +5,8 @@ use App::Hiveminder::Utils qw/get_text_from_editor_or_cmdline display_tasks
update_tasks/;
extends 'App::Hiveminder::Command';
-sub run {
- my ($self, $opt, $args) = @_;
+sub command {
+ my ($self, $args) = @_;
$args = join " ", @$args;
my $text = get_text_from_editor_or_cmdline($args);
@@ -22,7 +22,7 @@ sub run {
sub { (description => (join "\n", @text)) }) });
}
- print $ret, "\n";
+ return $ret;
}
__PACKAGE__->meta()->make_immutable();