Formal mechanism for retrying input
This allows for alias plugins with better error messages and better logging than with the $_[2] =~ s/// hack.
This commit is contained in:
parent
b3cd3833f1
commit
fbb178d5ac
3 changed files with 19 additions and 5 deletions
|
@ -18,6 +18,7 @@ sub import {
|
|||
*{"$caller\::REJECT"} = sub () { \3 };
|
||||
*{"$caller\::NEXT"} = sub () { \4 };
|
||||
*{"$caller\::DONE"} = sub () { \5 };
|
||||
*{"$caller\::REDO"} = sub () { \6 };
|
||||
*{"$caller\::slurp"} = \&RevBank::FileIO::slurp;
|
||||
*{"$caller\::spurt"} = \&RevBank::FileIO::spurt;
|
||||
*{"$caller\::rewrite"} = \&RevBank::FileIO::rewrite;
|
||||
|
|
|
@ -45,8 +45,13 @@ sub hook_abort($class, $cart, @) {
|
|||
say "\e[1;4mABORTING TRANSACTION.\e[0m";
|
||||
}
|
||||
|
||||
sub hook_invalid_input($class, $cart, $word, @) {
|
||||
say "$word: No such product, user, or command.";
|
||||
sub hook_invalid_input($class, $cart, $origword, $lastword, $allwords, @) {
|
||||
say "$origword: No such product, user, or command.";
|
||||
my @other = splice @$allwords, 1;
|
||||
if (@other) {
|
||||
$other[-1] =~ s/^/ and / if @other > 1;
|
||||
say "(Also tried as " . join(@other > 2 ? ", " : "", @other) . ".)";
|
||||
}
|
||||
}
|
||||
|
||||
sub hook_reject($class, $plugin, $reason, $abort, @) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue