Commit | Line | Data |
a9e4d3d0 |
1 | package App::Promulger::Command::newsub; |
2a007b5a |
2 | use strictures 1; |
3 | use autodie; |
a9e4d3d0 |
4 | |
5 | use App::Promulger -command; |
6 | use Promulger::List; |
7 | |
8 | sub abstract { |
9 | return "subscribes a user to a list"; |
10 | } |
11 | |
12 | sub 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'; |