+if ($OPT{'limit-queues'}) {
+ my @queue_ids;
+
+ for my $name (split ',', join ',', @{ $OPT{'limit-queues'} }) {
+ $name =~ s/^\s+//; $name =~ s/\s+$//;
+ my $queue = RT::Queue->new(RT->SystemUser);
+ $queue->Load($name);
+ if (!$queue->Id) {
+ die "Unable to load queue '$name'";
+ }
+ push @queue_ids, $queue->Id;
+ }
+
+ $args{Queues} = \@queue_ids;
+}
+
+if ($OPT{'limit-cfs'}) {
+ my @cf_ids;
+
+ for my $name (split ',', join ',', @{ $OPT{'limit-cfs'} }) {
+ $name =~ s/^\s+//; $name =~ s/\s+$//;
+
+ # numeric means id
+ if ($name =~ /^\d+$/) {
+ push @cf_ids, $name;
+ }
+ else {
+ my $cfs = RT::CustomFields->new(RT->SystemUser);
+ $cfs->Limit(FIELD => 'Name', VALUE => $name);
+ if (!$cfs->Count) {
+ die "Unable to load any custom field named '$name'";
+ }
+ push @cf_ids, map { $_->Id } @{ $cfs->ItemsArrayRef };
+ }
+ }
+
+ $args{CustomFields} = \@cf_ids;
+}
+