1 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # front-end for the "lei ls-mail-sync" sub-command
5 package PublicInbox::LeiLsMailSync;
8 use PublicInbox::LeiMailSync;
10 sub lei_ls_mail_sync {
11 my ($lei, $filter) = @_;
12 my $lms = $lei->lms or return;
13 my $opt = $lei->{opt};
14 my $re = $opt->{globoff} ? undef : $lei->glob2re($filter // '*');
15 $re //= qr/\Q$filter\E/;
16 my @f = $lms->folders;
17 @f = $opt->{'invert-match'} ? grep(!/$re/, @f) : grep(/$re/, @f);
18 if ($opt->{'local'} && !$opt->{remote}) {
19 @f = grep(!m!\A[a-z\+]+://!i, @f);
20 } elsif ($opt->{remote} && !$opt->{'local'}) {
21 @f = grep(m!\A[a-z\+]+://!i, @f);
23 my $ORS = $opt->{z} ? "\0" : "\n";
24 $lei->out(join($ORS, @f, ''));