standardize on strictures+autodie+Test::Most where applicable
[p5sagit/Promulger.git] / lib / App / Promulger / Command / newsub.pm
CommitLineData
a9e4d3d0 1package App::Promulger::Command::newsub;
2a007b5a 2use strictures 1;
3use autodie;
a9e4d3d0 4
5use App::Promulger -command;
6use Promulger::List;
7
8sub abstract {
9 return "subscribes a user to a list";
10}
11
12sub run {
13 my ($self, $opt, $args) = @_;
14 @$args >= 1 or die "pmg newsub needs a list name\n";
15
16 my $listname = $args->[0];
17 my $list = Promulger::List->resolve($listname);
18
243baf4d 19 if(!$list) {
a9e4d3d0 20 die "$listname doesn't exist\n";
21 }
22
23 if(@$args == 2) {
24 # got the subscriber as an arg
25 my $new_sub = $args->[1];
26 $list->subscribe($new_sub);
27 } else {
28 # reading from stdin
29 while(chomp(my $new_sub = <STDIN>)) {
30 $list->subscribe($new_sub);
31 }
32 }
33}
34
35'Make it so';