Cleanup: use subroutine signatures, remove deprecated methods.

The signatures feature has been "experimental" since Perl 5.20 (May 2014), but
expected to stay. After 8 years I'm ready to take the risk :)

Have added Perl v5.28 (June 2018) as the minimum requirement, even though the
current revbank should work with 5.20, to see if this bothers any users. Perl
v5.28 is in Debian "buster", which is now oldstable.
This commit is contained in:
Juerd Waalboer 2021-12-03 18:00:34 +01:00
parent 1661661ffd
commit eed0db7897
45 changed files with 233 additions and 444 deletions

View file

@ -1,4 +1,10 @@
package RevBank::Messages;
use v5.28;
use warnings;
use feature qw(signatures);
no warnings qw(experimental::signatures);
use RevBank::Global;
use base 'RevBank::Plugin';
@ -16,13 +22,11 @@ sub hook_startup {
say "\e[0m\n\n\nWelcome to the RevBank Shell, version $::VERSION\n";
}
sub hook_plugin_fail {
my ($class, $plugin, $error) = @_;
sub hook_plugin_fail($class, $plugin, $error, @) {
warn "Plugin '$plugin' failed: $error\n";
}
sub hook_cart_changed {
my ($class, $cart) = @_;
sub hook_cart_changed($class, $cart, @) {
$cart->size or return;
say "Pending:";
$cart->display;
@ -35,23 +39,19 @@ sub hook_cart_changed {
}
}
sub hook_abort {
my ($class, $cart) = @_;
sub hook_abort($class, $cart, @) {
say "\e[1;4mABORTING TRANSACTION.\e[0m";
}
sub hook_invalid_input {
my ($class, $cart, $word) = @_;
sub hook_invalid_input($class, $cart, $word, @) {
say "$word: No such product, user, or command.";
}
sub hook_reject {
my ($class, $plugin, $reason, $abort) = @_;
sub hook_reject($class, $plugin, $reason, $abort, @) {
say $abort ? $reason : "$reason Enter 'abort' to abort.";
}
sub hook_user_balance {
my ($class, $username, $old, $delta, $new) = @_;
sub hook_user_balance($class, $username, $old, $delta, $new, @) {
my $sign = $delta->cents >= 0 ? '+' : '-';
my $rood = $new->cents < 0 ? '31;' : '';
my $abs = $delta->abs;
@ -61,8 +61,7 @@ sub hook_user_balance {
printf "New balance for $username: $old $sign $abs = \e[${rood}1m$new\e[0m$warn\n",
}
sub hook_user_created {
my ($class, $username) = @_;
sub hook_user_created($class, $username, @) {
say "New account '$username' created.";
}