From: Chris Nehren Date: Sun, 4 Sep 2011 02:41:26 +0000 (-0400) Subject: move the --config option to be global, also add a command to unsubscribe a X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7e9dc6a62de19ce7003d7ae99f2d32d7174f95e8;p=p5sagit%2FPromulger.git move the --config option to be global, also add a command to unsubscribe a member. --- diff --git a/lib/App/Promulger.pm b/lib/App/Promulger.pm index 545f962..1cce07d 100644 --- a/lib/App/Promulger.pm +++ b/lib/App/Promulger.pm @@ -4,4 +4,12 @@ use warnings; use App::Cmd::Setup -app; +use Promulger::Config; + +sub global_opt_spec { + return ( + [ "config|c=s", "configuration file", { required => 1 } ], + ); +} + 1; diff --git a/lib/App/Promulger/Command.pm b/lib/App/Promulger/Command.pm index 32f6315..1c699c6 100644 --- a/lib/App/Promulger/Command.pm +++ b/lib/App/Promulger/Command.pm @@ -6,15 +6,9 @@ use App::Cmd::Setup -command; use Promulger::Config; -sub opt_spec { - return ( - [ "config|c=s", "configuration file", { required => 1 } ], - ); -} - sub validate_args { my ($self, $opt, $args) = @_; - my $cf = $opt->{config}; + my $cf = $self->app->global_options->{config}; unless(-e $cf) { die "Config file $cf doesn't exist\n"; diff --git a/lib/App/Promulger/Command/rmsub.pm b/lib/App/Promulger/Command/rmsub.pm new file mode 100644 index 0000000..f081f5b --- /dev/null +++ b/lib/App/Promulger/Command/rmsub.pm @@ -0,0 +1,27 @@ +package App::Promulger::Command::rmsub; +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 >= 2 or die "pmg newsub needs a list name and a departing member\n"; + + my $listname = $args->[0]; + my $list = Promulger::List->resolve($listname); + + if(!$list) { + die "$listname doesn't exist\n"; + } + + my $ex_sub = $args->[1]; + $list->unsubscribe($ex_sub); +} + +'Make it so'; diff --git a/lib/Promulger/Web.pm b/lib/Promulger/Web.pm index 4698cb5..f549f1d 100644 --- a/lib/Promulger/Web.pm +++ b/lib/Promulger/Web.pm @@ -43,7 +43,7 @@ sub dispatch_request { [ $self->show_subscriber($list, $subscriber) ] ] }, - sub (GET + /list/*/subscriber/*/unsubscribe) { + sub (POST + /list/*/subscriber/*/unsubscribe) { my ($self, $list, $subscriber) = @_; [ 200, @@ -116,7 +116,9 @@ method unsubscribe($list_name, $email) { method show_subscriber($list_name, $subscriber) { my $html = <<"HTML";

Subscriber ${subscriber}

-unsubscribe +
+ +
HTML }