From: Chris Nehren Date: Sat, 26 Jun 2010 12:58:28 +0000 (-0400) Subject: command for subscribing users X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a9e4d3d046a8a0cee97b2939a244c4c07e146334;p=p5sagit%2FPromulger.git command for subscribing users --- diff --git a/lib/App/Promulger/Command/newsub.pm b/lib/App/Promulger/Command/newsub.pm new file mode 100644 index 0000000..567221f --- /dev/null +++ b/lib/App/Promulger/Command/newsub.pm @@ -0,0 +1,37 @@ +package App::Promulger::Command::newsub; +use strict; +use warnings; + +use App::Promulger -command; +use Promulger::List; + +sub abstract { + return "subscribes a user to a list"; +} + +sub run { + my ($self, $opt, $args) = @_; + @$args >= 1 or die "pmg newsub needs a list name\n"; + + my $listname = $args->[0]; + my $list = Promulger::List->resolve($listname); + + if($list) { + $list->delete; + } else { + die "$listname doesn't exist\n"; + } + + if(@$args == 2) { + # got the subscriber as an arg + my $new_sub = $args->[1]; + $list->subscribe($new_sub); + } else { + # reading from stdin + while(chomp(my $new_sub = )) { + $list->subscribe($new_sub); + } + } +} + +'Make it so';