3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 03:33:06 +01:00

Show supported languages when invalid language given

This commit is contained in:
Pragmatic Software 2015-01-15 21:20:34 -08:00
parent b3081b9e9f
commit ac8dadb7f7

View File

@ -3,6 +3,8 @@
use warnings;
use strict;
use File::Basename;
my $language = shift @ARGV // 'c11';
$language = lc $language;
@ -11,7 +13,20 @@ eval {
require "$language.pm";
} or do {
print "Language '$language' is not supported.\n";
die $@;
my @languages = glob 'languages/*.pm';
my $comma = '';
print "Supported languages are: ";
foreach my $lang (sort @languages) {
$lang = basename($lang);
next if $lang =~ m/^_/;
$lang =~ s/\.pm$//;
print "$comma$lang";
$comma = ', ';
}
print "\n";
exit;
};
my $nick = shift @ARGV // (print "Missing nick argument.\n" and die);