diff --git a/applets/trans.pl b/applets/trans.pl index 473b03b1..a3bde62f 100755 --- a/applets/trans.pl +++ b/applets/trans.pl @@ -5,6 +5,8 @@ use warnings; use strict; +use Getopt::Long qw/GetOptionsFromString/; + if (not @ARGV) { print "Usage: trans [options] [source]:[targets] \n"; exit; @@ -17,9 +19,28 @@ $args =~ s/^\s+|\s+$//g; my $opts = '-j -no-ansi -no-autocorrect -no-browser -no-pager -no-play'; $opts .= ' -b' unless $args =~ /^-/; -if ($args =~ m/-(pager|browser|player|download|p|I|interactive|shell|emacs|E|x|4|6|ipv|inet|u|U|upgrade|user)/) { - print "I don't think so.\n"; - exit; +{ + my $opt_err; + local $SIG{__WARN__} = sub { + $opt_err = shift; + chomp $opt_err; + }; + + Getopt::Long::Configure('no_auto_abbrev', 'no_ignore_case'); + + my %h; + my @allowed = qw/V version H help M man T reference R reference-english S list-engines list-languages list-languages-english list-codes list-all L linguist e engine b brief d dictionary identify show-original show-original-phonetics show-translation show-translation-phonetics show-prompt-message show-languages show-original-dictionary show-dictionary show-alternatives hl host s sl source from t tl target to/; + my ($ret, $rest) = GetOptionsFromString($args, \%h, @allowed); + + if ($opt_err) { + print "$opt_err\n"; + exit; + } + + if ($ret != 1) { + print "Error parsing options.\n"; + exit; + } } my $result = `trans $opts $args`; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 66d23d0e..619f5179 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4874, + BUILD_REVISION => 4875, BUILD_DATE => "2025-07-19", };