From e63ecb6cec0021948fea4c09925d4b7511d39eff Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Fri, 9 May 2008 02:33:48 -0500 Subject: have the base command class pass in the arguments to the command as a list instead of an arrayref --- lib/App/Hiveminder/Command.pm | 2 +- lib/App/Hiveminder/Command/Braindump.pm | 4 ++-- lib/App/Hiveminder/Command/Create.pm | 5 ++--- lib/App/Hiveminder/Command/Delete.pm | 4 ++-- lib/App/Hiveminder/Command/List.pm | 4 ++-- lib/App/Hiveminder/Command/Todo.pm | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/App/Hiveminder/Command.pm b/lib/App/Hiveminder/Command.pm index d6f13df..f815874 100644 --- a/lib/App/Hiveminder/Command.pm +++ b/lib/App/Hiveminder/Command.pm @@ -14,7 +14,7 @@ has _hm => ( sub run { my ($self, $opt, $args) = @_; - my $result = $self->command($args); + my $result = $self->command(@$args); if (defined $result) { chomp $result; diff --git a/lib/App/Hiveminder/Command/Braindump.pm b/lib/App/Hiveminder/Command/Braindump.pm index 92786f3..0f4ac7b 100644 --- a/lib/App/Hiveminder/Command/Braindump.pm +++ b/lib/App/Hiveminder/Command/Braindump.pm @@ -13,11 +13,11 @@ App::Hiveminder::Command::Braindump - Create several tasks at once sub command_names { qw/braindump bd/ } sub command { - my ($self, $args) = @_; + my $self = shift; my $text = get_text_from_editor; return display_tasks($self->hm->braindump($text, returns => 'tasks', - tokens => [@$args])) + tokens => [@_])) unless $text eq ''; return ''; } diff --git a/lib/App/Hiveminder/Command/Create.pm b/lib/App/Hiveminder/Command/Create.pm index 25b1a0b..fd25429 100644 --- a/lib/App/Hiveminder/Command/Create.pm +++ b/lib/App/Hiveminder/Command/Create.pm @@ -14,10 +14,9 @@ App::Hiveminder::Command::Create - Create a new task sub command_names { qw/create c/ } sub command { - my ($self, $args) = @_; - $args = join " ", @$args; + my $self = shift; - my $text = get_text_from_editor_or_cmdline($args); + my $text = get_text_from_editor_or_cmdline(@_); return '' if $text eq ''; my @text = split "\n", $text; diff --git a/lib/App/Hiveminder/Command/Delete.pm b/lib/App/Hiveminder/Command/Delete.pm index 4c105b7..33552eb 100644 --- a/lib/App/Hiveminder/Command/Delete.pm +++ b/lib/App/Hiveminder/Command/Delete.pm @@ -13,10 +13,10 @@ App::Hiveminder::Command::Delete - Delete a task by locator sub command_names { qw/delete rm del/ } sub command { - my ($self, $args) = @_; + my $self = shift; # XXX: offer an interactive mode here, possibly my $ret = ''; - for my $locator (@$args) { + for my $locator (@_) { my $desc = display_tasks($self->hm->read_task($locator)); $ret .= "Deleted $desc\n"; eval { $self->hm->delete('Task', id => $self->hm->loc2id($locator)) }; diff --git a/lib/App/Hiveminder/Command/List.pm b/lib/App/Hiveminder/Command/List.pm index e7746a6..fe8f993 100644 --- a/lib/App/Hiveminder/Command/List.pm +++ b/lib/App/Hiveminder/Command/List.pm @@ -13,11 +13,11 @@ App::Hiveminder::Command::List - List tasks sub command_names { qw/list ls find/ } sub command { - my ($self, $args) = @_; + my $self = shift; return unless @_ > 0; return display_tasks($self->hm, - $self->hm->get_tasks(%{ parse_args @$args })); + $self->hm->get_tasks(%{ parse_args @_ })); } 1; diff --git a/lib/App/Hiveminder/Command/Todo.pm b/lib/App/Hiveminder/Command/Todo.pm index d5948eb..8381daa 100644 --- a/lib/App/Hiveminder/Command/Todo.pm +++ b/lib/App/Hiveminder/Command/Todo.pm @@ -13,8 +13,8 @@ App::Hiveminder::Command::Todo - Display the current todo list sub command_names { qw/todo t/ } sub command { - my ($self, $args) = @_; - my %args = %{ parse_args @$args }; + my $self = shift; + my %args = %{ parse_args @_ }; $args{complete_not} = 0 if exists $args{complete} && $args{complete} == 1 && !exists $args{complete_not}; -- cgit v1.2.3-54-g00ecf