diff options
| author | fukachan <fukachan> | 2001-03-25 02:45:27 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-03-25 02:45:27 +0000 |
| commit | ef9ee19d64381005ad5e682d392e251ddf71496d (patch) | |
| tree | d18e50ccea6d3713fed299b1b7948c548856bd58 /fml | |
| parent | 95a729878f05341769275a3ebcbccdc7c5eb00da (diff) | |
| download | fml8-ef9ee19d64381005ad5e682d392e251ddf71496d.tar.gz fml8-ef9ee19d64381005ad5e682d392e251ddf71496d.tar.bz2 fml8-ef9ee19d64381005ad5e682d392e251ddf71496d.zip | |
rewritten to use the current FML::Command style
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Process/Command.pm | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm index 30ba08e3..ea9cc619 100644 --- a/fml/lib/FML/Process/Command.pm +++ b/fml/lib/FML/Process/Command.pm @@ -17,9 +17,12 @@ use FML::Process::Kernel; use FML::Log qw(Log LogWarn LogError); use FML::Config; +@ISA = qw(FML::Process::Kernel); + + =head1 NAME -FML::Process::Command -- fml5 command processor. +FML::Process::Command -- fml5 command wrapper. =head1 SYNOPSIS @@ -30,15 +33,13 @@ See L<FML::Process::Flow> for details of flow. =head1 DESCRIPTION -C<NOT YET IMPLERMENTED>. +C<FML::Process::Command> is a command wrapper and top level +dispatcher. +It kicks off C<FML::Command>->C<$command($curproc, $args)> for each +C<$command>. =cut - -require Exporter; -@ISA = qw(FML::Process::Kernel Exporter); - - sub new { my ($self, $args) = @_; @@ -73,7 +74,7 @@ sub run # Q: the mail sender is a ML member? if ($cred->is_member) { - _evaluate_command( $curproc ); + $curproc->_evaluate_command($args); } } $curproc->unlock(); @@ -92,10 +93,12 @@ sub finish # It resolves your customized command easily. sub _evaluate_command { - my ( $curproc ) = @_; - my $config = $curproc->{ config }; - my $body = $curproc->{ incoming_message }->{ body }->get_content_body; - my @body = split(/\n/, $body); + my ($curproc, $args) = @_; + my $config = $curproc->{ config }; + my $ml_name = $config->{ ml_name }; + my $argv = $config->{ main_cf }->{ ARGV }; + my $body = $curproc->{ incoming_message }->{ body }->get_content_body; + my @body = split(/\n/, $body); for my $command (@body) { my $is_valid = @@ -103,8 +106,24 @@ sub _evaluate_command ? 'yes' : 'no'; Log("command = " . $command . " (valid?=$is_valid)"); next if $is_valid eq 'no'; - eval qq{ require FML::Command::$command; }; - if ($@) { Log($@);} + + # arguments to pass off to each method + my $optargs = { + command => $command, + ml_name => $ml_name, + argv => $argv, + args => $args, + }; + + my $pkg = 'FML::Command'; + eval qq{ require $pkg; $pkg->import();}; + unless ($@) { + my $obj = new $pkg; + $obj->$command($curproc, $optargs); + } + else { + Log($@); + } } } |
