Commands case insensitive + whitespace allowed around abort
This commit is contained in:
parent
f81996e6ac
commit
7cbedf40ea
1 changed files with 12 additions and 11 deletions
23
revbank
23
revbank
|
@ -61,6 +61,7 @@ my @commands = qw/
|
||||||
sub prompt {
|
sub prompt {
|
||||||
my ($prompt, $completions) = @_;
|
my ($prompt, $completions) = @_;
|
||||||
$completions ||= [];
|
$completions ||= [];
|
||||||
|
push @$completions, 'abort';
|
||||||
|
|
||||||
my @matches;
|
my @matches;
|
||||||
$readline->Attribs->{completion_entry_function} = sub {
|
$readline->Attribs->{completion_entry_function} = sub {
|
||||||
|
@ -82,7 +83,7 @@ sub prompt {
|
||||||
$input =~ s/.\cH// while $input =~ /.\cH/;
|
$input =~ s/.\cH// while $input =~ /.\cH/;
|
||||||
$input =~ s/^\cH+//;
|
$input =~ s/^\cH+//;
|
||||||
|
|
||||||
if ($input =~ /^abort$/) {
|
if ($input =~ /^\s*abort\s*$/i) {
|
||||||
print "$at\n";
|
print "$at\n";
|
||||||
next LINE; # Whoa, scary out-of-scope jump! But it works :)
|
next LINE; # Whoa, scary out-of-scope jump! But it works :)
|
||||||
}
|
}
|
||||||
|
@ -243,25 +244,25 @@ sub parse_manual {
|
||||||
|
|
||||||
sub parse_command {
|
sub parse_command {
|
||||||
my ($command, $line) = @_;
|
my ($command, $line) = @_;
|
||||||
if ($command =~ /^(?:h|help|\?!?|wtf|omgwtfbbq)$/) {
|
if ($command =~ /^(?:h|help|\?!?|wtf|omgwtfbbq)$/i) {
|
||||||
return help();
|
return help();
|
||||||
} elsif ($command =~ /^(?:examples)$/) {
|
} elsif ($command =~ /^(?:examples)$/i) {
|
||||||
return examples();
|
return examples();
|
||||||
} elsif ($command =~ /^(?:deposit)$/) {
|
} elsif ($command =~ /^(?:deposit)$/i) {
|
||||||
return deposit($line);
|
return deposit($line);
|
||||||
} elsif ($command =~ /^(?:take|steal)$/) {
|
} elsif ($command =~ /^(?:take|steal)$/i) {
|
||||||
return take($line);
|
return take($line);
|
||||||
} elsif ($command =~ /^(?:give)$/) {
|
} elsif ($command =~ /^(?:give)$/i) {
|
||||||
return give($line);
|
return give($line);
|
||||||
} elsif ($command =~ /^(?:undo)$/) {
|
} elsif ($command =~ /^(?:undo)$/i) {
|
||||||
return undo($line);
|
return undo($line);
|
||||||
} elsif ($command =~ /^(?:ls|list)$/) {
|
} elsif ($command =~ /^(?:ls|list)$/i) {
|
||||||
return list();
|
return list();
|
||||||
} elsif ($command =~ /^(?:shame)$/) {
|
} elsif ($command =~ /^(?:shame)$/i) {
|
||||||
return shame();
|
return shame();
|
||||||
} elsif ($command =~ /^(?:edit)$/) {
|
} elsif ($command =~ /^(?:edit)$/i) {
|
||||||
return edit();
|
return edit();
|
||||||
} elsif ($command =~ /^(?:restart)$/) {
|
} elsif ($command =~ /^(?:restart)$/i) {
|
||||||
exec $0;
|
exec $0;
|
||||||
die "exec() failed. You'll have to restart revbank yourself :P\n";
|
die "exec() failed. You'll have to restart revbank yourself :P\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue