-my $spy = $class->new($dbname, "admin", "fruitbat");
-$spy->targets(@targets) if @targets;
-$spy->initialise();
-my $res = $spy->check($opts{t});
+if ($opts{M} && $opts{M} > 0) {
+ no warnings;
+ $ZOOM::IRSpy::xslt_max_depth = $opts{M};
+}
+if ($opts{d}) {
+ no warnings;
+ $ZOOM::IRSpy::debug = $opts{d};
+}
+
+my $spy = $class->new($dbname, "admin", "fruitbat", $opts{n});
+if (@targets) {
+ $spy->targets(@targets);
+} elsif ($opts{f}) {
+ $spy->find_targets($opts{f});
+} elsif (!$opts{a}) {
+ print STDERR "$0: specify -a, -f <query> or list of targets\n";
+ exit 2;
+}
+
+if (defined $opts{m}) {
+ my($n, $i) = ($opts{m} =~ /^(\d+),(\d+)$/);
+ if (!defined $n) {
+ print STDERR "$0: argument to -m must be of the form <n>,<i>\n";
+ exit 3;
+ }
+ $spy->restrict_modulo($n, $i);
+}
+
+$spy->initialise($opts{t});
+my $res = $spy->check();