From cb0e9d42b799c7489c3b8328cfcae1e1500bc7a0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 1 May 2021 06:21:16 +0000 Subject: lei: rename ls-sync to ls-mail-sync This allows tab-completion for "ls-search" to work with fewer characters ("ls-s" instead of "ls-se"), and I expect "ls-search" to be used more frequently than "ls-mail-sync". This also matches the --mail-sync switch of "lei import" --- MANIFEST | 2 +- lib/PublicInbox/LEI.pm | 2 +- lib/PublicInbox/LeiLsMailSync.pm | 29 +++++++++++++++++++++++++++++ lib/PublicInbox/LeiLsSync.pm | 29 ----------------------------- t/lei-import-imap.t | 4 ++-- t/lei-import-maildir.t | 4 ++-- 6 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 lib/PublicInbox/LeiLsMailSync.pm delete mode 100644 lib/PublicInbox/LeiLsSync.pm diff --git a/MANIFEST b/MANIFEST index 82f25735..b7e55793 100644 --- a/MANIFEST +++ b/MANIFEST @@ -202,8 +202,8 @@ lib/PublicInbox/LeiInput.pm lib/PublicInbox/LeiInspect.pm lib/PublicInbox/LeiLcat.pm lib/PublicInbox/LeiLsLabel.pm +lib/PublicInbox/LeiLsMailSync.pm lib/PublicInbox/LeiLsSearch.pm -lib/PublicInbox/LeiLsSync.pm lib/PublicInbox/LeiMailSync.pm lib/PublicInbox/LeiMirror.pm lib/PublicInbox/LeiOverview.pm diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index bb67fc0b..5d701d5e 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -170,7 +170,7 @@ our %CMD = ( # sorted in order of importance/use: 'ls-external' => [ '[FILTER]', 'list publicinbox|extindex locations', qw(format|f=s z|0 globoff|g invert-match|v local remote), @c_opt ], 'ls-label' => [ '', 'list labels', qw(z|0 stats:s), @c_opt ], -'ls-sync' => [ '', 'list sync folders', +'ls-mail-sync' => [ '', 'list mail sync folders', qw(z|0 z|0 globoff|g invert-match|v local remote), @c_opt ], 'forget-external' => [ 'LOCATION...|--prune', 'exclude further results from a publicinbox|extindex', diff --git a/lib/PublicInbox/LeiLsMailSync.pm b/lib/PublicInbox/LeiLsMailSync.pm new file mode 100644 index 00000000..2b3d326d --- /dev/null +++ b/lib/PublicInbox/LeiLsMailSync.pm @@ -0,0 +1,29 @@ +# Copyright (C) 2021 all contributors +# License: AGPL-3.0+ + +# front-end for the "lei ls-sync" sub-command +package PublicInbox::LeiLsMailSync; +use strict; +use v5.10.1; +use PublicInbox::LeiMailSync; + +sub lei_ls_mail_sync { + my ($lei, $filter) = @_; + my $sto = $lei->_lei_store or return; + my $lms = $sto->search->lms or return; + my $opt = $lei->{opt}; + my $re; + $re = defined($filter) ? qr/\Q$filter\E/ : qr/./ if $opt->{globoff}; + $re //= $lei->glob2re($filter // '*'); + my @f = $lms->folders; + @f = $opt->{'invert-match'} ? grep(!/$re/, @f) : grep(/$re/, @f); + if ($opt->{'local'} && !$opt->{remote}) { + @f = grep(!m!\A[a-z\+]+://!i, @f); + } elsif ($opt->{remote} && !$opt->{'local'}) { + @f = grep(m!\A[a-z\+]+://!i, @f); + } + my $ORS = $opt->{z} ? "\0" : "\n"; + $lei->out(join($ORS, @f, '')); +} + +1; diff --git a/lib/PublicInbox/LeiLsSync.pm b/lib/PublicInbox/LeiLsSync.pm deleted file mode 100644 index 71f111a9..00000000 --- a/lib/PublicInbox/LeiLsSync.pm +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2021 all contributors -# License: AGPL-3.0+ - -# front-end for the "lei ls-sync" sub-command -package PublicInbox::LeiLsSync; -use strict; -use v5.10.1; -use PublicInbox::LeiMailSync; - -sub lei_ls_sync { - my ($lei, $filter) = @_; - my $sto = $lei->_lei_store or return; - my $lms = $sto->search->lms or return; - my $opt = $lei->{opt}; - my $re; - $re = defined($filter) ? qr/\Q$filter\E/ : qr/./ if $opt->{globoff}; - $re //= $lei->glob2re($filter // '*'); - my @f = $lms->folders; - @f = $opt->{'invert-match'} ? grep(!/$re/, @f) : grep(/$re/, @f); - if ($opt->{'local'} && !$opt->{remote}) { - @f = grep(!m!\A[a-z\+]+://!i, @f); - } elsif ($opt->{remote} && !$opt->{'local'}) { - @f = grep(m!\A[a-z\+]+://!i, @f); - } - my $ORS = $opt->{z} ? "\0" : "\n"; - $lei->out(join($ORS, @f, '')); -} - -1; diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t index c977c68e..3a1fff4c 100644 --- a/t/lei-import-imap.t +++ b/t/lei-import-imap.t @@ -22,8 +22,8 @@ test_lei({ tmpdir => $tmpdir }, sub { is_deeply(json_utf8->decode($lei_out), {}, 'no inspect stats, yet'); lei_ok('import', $url); - lei_ok 'ls-sync'; - like($lei_out, qr!\A\Q$url\E;UIDVALIDITY=\d+\n\z!, 'ls-sync'); + lei_ok 'ls-mail-sync'; + like($lei_out, qr!\A\Q$url\E;UIDVALIDITY=\d+\n\z!, 'ls-mail-sync'); chomp(my $u = $lei_out); lei_ok('import', $u, \'UIDVALIDITY match in URL'); $u =~ s/;UIDVALIDITY=(\d+)\s*/;UIDVALIDITY=9$1/s; diff --git a/t/lei-import-maildir.t b/t/lei-import-maildir.t index 808e1a73..02fe43e1 100644 --- a/t/lei-import-maildir.t +++ b/t/lei-import-maildir.t @@ -40,8 +40,8 @@ test_lei(sub { is_deeply($inspect, { sync => { "maildir:$md" => [ 'x:2,S' ] } }, 'maildir sync info as expected'); - lei_ok qw(ls-sync); - is($lei_out, "maildir:$md\n", 'ls-sync as expected'); + lei_ok qw(ls-mail-sync); + is($lei_out, "maildir:$md\n", 'ls-mail-sync as expected'); lei_ok(qw(import), $md, \'import Maildir again'); $imp_err = $lei_err; -- cgit v1.2.3-24-ge0c7