diff options
| author | fukachan <fukachan> | 2001-10-10 14:56:01 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-10-10 14:56:01 +0000 |
| commit | 808a113702ef174d4765da9226d7d2ec28b3cab3 (patch) | |
| tree | 58dfef358746f7a04133c2f9226b11dbac742290 /fml | |
| parent | 0695caede6e857b51e540f0d7741c27ea23d8dcc (diff) | |
| download | fml8-808a113702ef174d4765da9226d7d2ec28b3cab3.tar.gz fml8-808a113702ef174d4765da9226d7d2ec28b3cab3.tar.bz2 fml8-808a113702ef174d4765da9226d7d2ec28b3cab3.zip | |
define prototype for reply_message_nl() for natural language
modified to use it
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Process/Command.pm | 30 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Kernel.pm | 21 |
2 files changed, 44 insertions, 7 deletions
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm index 4e9f1225..9e864c0d 100644 --- a/fml/lib/FML/Process/Command.pm +++ b/fml/lib/FML/Process/Command.pm @@ -4,7 +4,7 @@ # Copyright (C) 2000,2001 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Command.pm,v 1.12 2001/10/10 03:12:51 fukachan Exp $ +# $FML: Command.pm,v 1.13 2001/10/10 10:08:06 fukachan Exp $ # package FML::Process::Command; @@ -138,7 +138,7 @@ sub _evaluate_command my @body = split(/\n/, $body); my $prompt = $config->{ command_prompt } || '>>>'; - $curproc->reply_message("result for your command requests follows:\n"); + $curproc->reply_message("result for your command requests follows:"); COMMAND: for my $command (@body) { @@ -163,13 +163,31 @@ sub _evaluate_command use FML::Command; my $obj = new FML::Command; if (defined $obj) { - $curproc->reply_message("$prompt $command"); + $curproc->reply_message("\n$prompt $command"); eval q{ $obj->$comname($curproc, $optargs); }; - if ($@) { - LogError("fail to exec ${command}"); - LogError($@); + + unless ($@) { + $curproc->reply_message_nl('general.success', "ok."); + } + else { + $curproc->reply_message_nl('general.fail', "fail."); + LogError("command ${comname} fail"); + if ($@ =~ /^(.*)at/) { + my $reason = $1; + my $nlinfo = $obj->error_nl(); + + if (defined $nlinfo) { + my $class = $nlinfo->{ class }; + my $args = $nlinfo->{ args }; + $curproc->reply_message_nl($class, $reason, $args); + } + else { + $curproc->reply_message($reason); + } + Log($reason); # pick up reason + } } } diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm index 4d4ea657..75b28da3 100644 --- a/fml/lib/FML/Process/Kernel.pm +++ b/fml/lib/FML/Process/Kernel.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Kernel.pm,v 1.53 2001/10/08 20:25:53 fukachan Exp $ +# $FML: Kernel.pm,v 1.54 2001/10/10 03:15:19 fukachan Exp $ # package FML::Process::Kernel; @@ -526,6 +526,25 @@ sub reply_message } +=head2 C<reply_message_nl($class, $default_msg, $args)> + +This is a wrapper for C<reply_message()> with natural language support. +The message in natural language corresponding with C<$class> is sent. +If translation fails, $default_msg, English by default, is used. + +We need parameters in some cases. +They are stored in $args if needed. + +=cut + + +sub reply_message_nl +{ + my ($curproc, $class, $default_msg, $args) = @_; + $curproc->reply_message($default_msg); +} + + =head2 C<inform_reply_messages($args)> inform the error messages to the sender or maintainer. |
