summaryrefslogtreecommitdiffstats
path: root/lib/App/Hiveminder/Command/Create.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/Hiveminder/Command/Create.pm')
-rw-r--r--lib/App/Hiveminder/Command/Create.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/App/Hiveminder/Command/Create.pm b/lib/App/Hiveminder/Command/Create.pm
new file mode 100644
index 0000000..6295a52
--- /dev/null
+++ b/lib/App/Hiveminder/Command/Create.pm
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+package App::Hiveminder::Command::Create;
+use Moose;
+use App::Hiveminder::Utils qw/get_text_from_editor_or_cmdline display_tasks
+ update_tasks/;
+extends 'App::Hiveminder::Command';
+
+sub command {
+ my ($self, $args) = @_;
+ $args = join " ", @$args;
+
+ my $text = get_text_from_editor_or_cmdline($args);
+ return '' if $text eq '';
+ my @text = split "\n", $text;
+
+ my $task = $self->hm->create_task(shift @text);
+ my $ret = display_tasks($self->hm, $task);
+
+ if (@text > 0) {
+ $ret = display_tasks($self->hm,
+ @{ update_tasks($self->hm, [$self->hm->id2loc($task->{id})],
+ sub { (description => (join "\n", @text)) }) });
+ }
+
+ return $ret;
+}
+
+__PACKAGE__->meta()->make_immutable();
+1;