added input filter to --only
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 15 May 2006 17:38:22 +0000 (17:38 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 15 May 2006 17:38:22 +0000 (17:38 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@510 07558da8-63fa-0310-ba24-9fe276d99e06

run.pl

diff --git a/run.pl b/run.pl
index b8b0f52..ac0679a 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -42,10 +42,13 @@ limit loading to 100 records
 
 remove database and Hyper Estraier index before indexing
 
-=item --only=database_name
+=item --only=database_name/input_filter
 
 reindex just single database (legacy name is --one)
 
+C</input_filter> is optional part which can be C<name>
+or C<type> from input
+
 =item --config conf/config.yml
 
 path to YAML configuration file
@@ -70,7 +73,7 @@ my $limit;
 my $clean = 0;
 my $config = 'conf/config.yml';
 my $debug = 0;
-my $only_db_name;
+my $only_filter;
 my $force_set = 0;
 my $stats = 0;
 
@@ -78,8 +81,8 @@ GetOptions(
        "limit=i" => \$limit,
        "offset=i" => \$offset,
        "clean" => \$clean,
-       "one=s" => \$only_db_name,
-       "only=s" => \$only_db_name,
+       "one=s" => \$only_filter,
+       "only=s" => \$only_filter,
        "config" => \$config,
        "debug" => \$debug,
        "force-set" => \$force_set,
@@ -108,7 +111,8 @@ my $start_t = time();
 
 while (my ($database, $db_config) = each %{ $config->{databases} }) {
 
-       next if ($only_db_name && $database !~ m/$only_db_name/i);
+       my ($only_database,$only_input) = split(m#/#, $only_filter);
+       next if ($only_database && $database !~ m/$only_database/i);
 
        my $indexer;
 
@@ -178,6 +182,8 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
 
        foreach my $input (@inputs) {
 
+               next if ($only_input && $input->{name} =~ m#$only_input#i || $input->{type} =~ m#$only_input#i);
+
                my $type = lc($input->{type});
 
                die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs));