/[notice-sender]/trunk/sender.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/sender.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by dpavlin, Sat May 14 12:31:27 2005 UTC revision 9 by dpavlin, Sat May 14 13:21:35 2005 UTC
# Line 9  use Data::Dumper; Line 9  use Data::Dumper;
9    
10  sender.pl - command line notify sender utility  sender.pl - command line notify sender utility
11    
12    =head1 SYNOPSYS
13    
14     sender.pl --add=mylist members.txt
15     sender.pl --list[=mylist]
16     sender.pl --queue=mylist message.txt
17     sender.pl --send=mylist
18    
19    =head2 All options
20    
21    =over 20
22    
23    =item --debug
24    
25    Turn on debugging output from C<Class::DBI>
26    
27  =cut  =cut
28    
29  my ($list_opt,$debug) = (0,0);  my ($list_opt,$debug) = (0,0);
# Line 16  my $add_opt; Line 31  my $add_opt;
31  my $queue_opt;  my $queue_opt;
32    
33  my $result = GetOptions(  my $result = GetOptions(
34          "list"  => \$list_opt,          "list:s" => \$list_opt,
35          "add=s" => \$add_opt,          "add=s" => \$add_opt,
36          "queue=s" => \$queue_opt,          "queue=s" => \$queue_opt,
37          "debug" => \$debug,          "debug" => \$debug,
# Line 40  my $user_list = $loader->find_class('use Line 55  my $user_list = $loader->find_class('use
55  my $messages = $loader->find_class('messages');  my $messages = $loader->find_class('messages');
56  my $message_list = $loader->find_class('message_list');  my $message_list = $loader->find_class('message_list');
57    
58  if ($list_opt) {  =item --list[=list_name]
59          foreach my $list ($lists->retrieve_all) {  
60    List all available lists and users on them. Optional value to list
61    (like C<--list=list_name>) will produce users just on that list.
62    
63    =cut
64    
65    if (defined($list_opt)) {
66            my @lists;
67            if ($list_opt ne '') {
68                    @lists = $lists->search( name=> $list_opt )->first || die "can't find list $list_opt";
69            } else {
70                    @lists = $lists->retrieve_all;
71            }
72    
73            foreach my $list (@lists) {
74                  print $list->name,"\n";                  print $list->name,"\n";
75                  foreach my $user_on_list ($user_list->search(list_id => $list->id)) {                  foreach my $user_on_list ($user_list->search(list_id => $list->id)) {
76                          my $user = $users->retrieve( id => $user_on_list->user_id );                          my $user = $users->retrieve( id => $user_on_list->user_id );
77                          print "\t",$user->full_name," <", $user->email, ">\n";                          print "\t",$user->full_name," <", $user->email, ">\n";
78                  }                  }
79          }          }
80    
81    =item --add=list_name
82    
83    Add users to list. Users are stored in file (which can be supplied as
84    argument) or read from C<STDIN>. List should be in following format:
85    
86     email@example.com      Optional full name of person
87     dpavlin@rot13.org      Dobrica Pavlinusic
88    
89    =cut
90    
91  } elsif ($add_opt) {  } elsif ($add_opt) {
92          #my $noticer = $loader->find_class('Noticer') || die "can't find my class!";          #my $noticer = $loader->find_class('Noticer') || die "can't find my class!";
93          my $list = $lists->find_or_create({          my $list = $lists->find_or_create({
# Line 79  if ($list_opt) { Line 119  if ($list_opt) {
119    
120          print "list ",$list->name," has $added users\n";          print "list ",$list->name," has $added users\n";
121    
122    =item --queue=list_name
123    
124    Queue message for later delivery. Message can be read from file (specified as
125    argument) or read from C<STDIN>.
126    
127    =cut
128    
129  } elsif ($queue_opt) {  } elsif ($queue_opt) {
130          my $this_list = $lists->search(          my $this_list = $lists->search(
131                  name => $queue_opt,                  name => $queue_opt,
# Line 105  if ($list_opt) { Line 152  if ($list_opt) {
152          print "added message ",$this_message->id, " to list ",$this_list->name,"\n";          print "added message ",$this_message->id, " to list ",$this_list->name,"\n";
153    
154  } else  {  } else  {
155          die $0.'          die "see perldoc $0 for help";
         --list                          show all lists and users  
         --add=name_of_list < users.txt  add users (email@example.com full name)  
         --queue=name_of_list < message  queue message for sending to list  
         --debug  
 ';  
156  }  }
157    
158    =back
159    
160    =head1 AUTHOR
161    
162    Dobrica Pavlinusic <dpavlin@rot13.org>
163    
164    =cut
165    

Legend:
Removed from v.6  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26