diff options
author | Eric Wong <e@80x24.org> | 2021-05-25 11:01:35 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-05-25 18:42:08 +0000 |
commit | 172d2d126cb9c0fa78b41a01f285f9294cc78f15 (patch) | |
tree | 1464accda86b16e095d756904da81ec6353c81b1 /lib/PublicInbox/LeiExportKw.pm | |
parent | 30bf4d7a2a8c1cf933ce8c6187559518423a123a (diff) | |
download | public-inbox-172d2d126cb9c0fa78b41a01f285f9294cc78f15.tar.gz |
This lets us have a more consistent UX for mapping easily-typed command-line arguments to canonical folder locations.
Diffstat (limited to 'lib/PublicInbox/LeiExportKw.pm')
-rw-r--r-- | lib/PublicInbox/LeiExportKw.pm | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm index fabc01f8..92c3aa43 100644 --- a/lib/PublicInbox/LeiExportKw.pm +++ b/lib/PublicInbox/LeiExportKw.pm @@ -95,7 +95,6 @@ lei mail_sync uninitialized, see lei-import(1) EOM my $opt = $lei->{opt}; my $all = $opt->{all}; - my @all = $lms->folders; if (defined $all) { # --all=<local|remote> my %x = map { $_ => $_ } split(/,/, $all); my @ok = grep(defined, delete(@x{qw(local remote), ''})); @@ -107,6 +106,7 @@ EOM EOM } my (%seen, @inc); + my @all = $lms->folders; for my $ok (@ok) { if ($ok eq 'local') { @inc = grep(!m!\A[a-z0-9\+]+://!i, @all); @@ -125,35 +125,9 @@ EOM no --mail-sync folders known to lei EOM } else { - my %all = map { $_ => 1 } @all; - my @no; - for (@folders) { - next if $all{$_}; # ok - if (-d "$_/new" && -d "$_/cur") { - my $d = 'maildir:'.$lei->abs_path($_); - push(@no, $_) unless $all{$d}; - $_ = $d; - } elsif (m!\Aimaps?://!i) { - my $orig = $_; - my $res = $lms->match_imap_url($orig, $all); - if (ref $res) { - $_ = $$res; - $lei->qerr(<<EOM); -# using `$res' instead of `$orig' -EOM - } else { - $lei->err($res) if defined $res; - push @no, $orig; - } - } else { - push @no, $_; - } - } - my $no = join("\n\t", @no); - return $lei->fail(<<EOF) if @no; -No sync information for: $no -Run `lei ls-mail-sync' to display valid choices -EOF + my $err = $lms->arg2folder($lei, \@folders); + $lei->qerr(@{$err->{qerr}}) if $err->{qerr}; + return $lei->fail($err->{fail}) if $err->{fail}; } my $self = bless { lse => $lse }, __PACKAGE__; $lei->{opt}->{'mail-sync'} = 1; # for prepare_inputs |