about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiRefreshMailSync.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-21 07:41:55 +0000
committerEric Wong <e@80x24.org>2021-09-21 19:18:35 +0000
commit8b91bd5f929bf166ee3a79dec43fba0e68b1dc8e (patch)
tree99a83624c6c34d8f0f7577e259481b23c4619353 /lib/PublicInbox/LeiRefreshMailSync.pm
parent1ed1a566c7d300ab8afb604b2e7c939299318005 (diff)
downloadpublic-inbox-8b91bd5f929bf166ee3a79dec43fba0e68b1dc8e.tar.gz
"lei export-kw" no longer completes for anonymous sources.

More commands use "lei refresh-mail-sync" as a basis for their
completion work, as well.

";AUTH=ANONYMOUS@" is stripped from completions since it was
preventing bash completion from working on AUTH=ANONYMOUS IMAP
URLs.  I'm not sure if there's a better way, but all of our code
works fine without specifying AUTH=ANONYMOUS as a command-line
arg.

Finally, we fallback to using more candidates if none can
be found, allowing multiple URLs to be completed.
Diffstat (limited to 'lib/PublicInbox/LeiRefreshMailSync.pm')
-rw-r--r--lib/PublicInbox/LeiRefreshMailSync.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiRefreshMailSync.pm b/lib/PublicInbox/LeiRefreshMailSync.pm
index 51e89b23..eb842843 100644
--- a/lib/PublicInbox/LeiRefreshMailSync.pm
+++ b/lib/PublicInbox/LeiRefreshMailSync.pm
@@ -7,7 +7,7 @@ package PublicInbox::LeiRefreshMailSync;
 use strict;
 use v5.10.1;
 use parent qw(PublicInbox::IPC PublicInbox::LeiInput);
-use PublicInbox::LeiExportKw;
+use PublicInbox::LeiImport;
 use PublicInbox::InboxWritable qw(eml_from_path);
 use PublicInbox::Import;
 
@@ -97,8 +97,16 @@ sub ipc_atfork_child { # needed for PublicInbox::LeiPmdir
         undef;
 }
 
+sub _complete_refresh_mail_sync {
+        my ($lei, @argv) = @_;
+        my $lms = $lei->lms or return ();
+        my $match_cb = $lei->complete_url_prepare(\@argv);
+        my @k = $lms->folders($argv[-1], 1);
+        my @m = map { $match_cb->($_) } @k;
+        @m ? @m : @k
+}
+
 no warnings 'once';
-*_complete_refresh_mail_sync = \&PublicInbox::LeiExportKw::_complete_export_kw;
 *net_merge_all_done = \&PublicInbox::LeiInput::input_only_net_merge_all_done;
 
 1;