- if (-f $x) {
- open my $fh, '<', $x or return $lei->child_error(1 >> 8, <<"");
-unable to open $x: $!
-
- _import_fh($lei, $fh, $x);
- } elsif (-d _ && (-d "$x/cur" || -d "$x/new")) {
- PublicInbox::MdirReader::maildir_each_file($x,
+ if ($input =~ m!\Aimaps?://!i) {
+ $lei->{net}->imap_each($input, \&_import_net, $lei->{sto},
+ $lei->{opt}->{kw});
+ return;
+ } elsif ($input =~ m!\A(?:nntps?|s?news)://!i) {
+ $lei->{net}->nntp_each($input, \&_import_net, $lei->{sto}, 0);
+ return;
+ } elsif ($input =~ s!\A([a-z0-9]+):!!i) {
+ $ifmt = lc $1;
+ }
+ if (-f $input) {
+ my $m = $lei->{opt}->{'lock'} // ($ifmt eq 'eml' ? ['none'] :
+ PublicInbox::MboxLock->defaults);
+ my $mbl = PublicInbox::MboxLock->acq($input, 0, $m);
+ _import_fh($lei, $mbl->{fh}, $input, $ifmt);
+ } elsif (-d _ && (-d "$input/cur" || -d "$input/new")) {
+ return $lei->fail(<<EOM) if $ifmt && $ifmt ne 'maildir';
+$input appears to a be a maildir, not $ifmt
+EOM
+ PublicInbox::MdirReader::maildir_each_eml($input,