3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Added -search option to dict.org.pl

This commit is contained in:
Pragmatic Software 2010-03-28 12:00:35 +00:00
parent a5618c41a1
commit 1131ab8bba

View File

@ -103,11 +103,16 @@ sub define_word
my $comma = '';
my $def_type = $config->def_type;
my $def_contains = $config->def_contains;
# normalize '*' to '.*'
$def_type =~ s/\.\*/*/g;
$def_type =~ s/\*/.*/g;
# normalize '*' to '.*'
$def_contains =~ s/\.\*/*/g;
$def_contains =~ s/\*/.*/g;
eval {
foreach my $type (keys %$defs) {
next if $type eq 'word';
@ -115,6 +120,7 @@ sub define_word
print "$comma$type: " if length $type;
foreach my $number (sort { $a <=> $b } keys %{ $defs->{$type} }) {
next unless $number >= $config->def_number;
next unless $defs->{$type}{$number} =~ m/$def_contains/i;
print "$comma" unless $number == 1;
print "$number) $defs->{$type}{$number}";
$comma = ", ";
@ -326,6 +332,7 @@ sub initialise
$config->define('database', { ARGCOUNT => 1, ALIAS => 'd' });
$config->define('def_number', { ARGCOUNT => 1, ALIAS => 'n', DEFAULT => 1 });
$config->define('def_type', { ARGCOUNT => 1, ALIAS => 't', DEFAULT => '*'});
$config->define('def_contains', { ARGCOUNT => 1, ALIAS => 'search', DEFAULT => '*'});
=cut
$config->define('match', { ARGCOUNT => 0, ALIAS => 'm' });