about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiImport.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/LeiImport.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/LeiImport.pm')
-rw-r--r--lib/PublicInbox/LeiImport.pm12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index 3c30db8d..397292d4 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -121,12 +121,14 @@ sub lei_import { # the main "lei import" method
 
 sub _complete_import {
         my ($lei, @argv) = @_;
-        my $match_cb = $lei->complete_url_prepare(\@argv);
-        my @m = map { $match_cb->($_) } $lei->url_folder_cache->keys;
-        my %f = map { $_ => 1 } @m;
+        my ($re, $cur, $match_cb) = $lei->complete_url_prepare(\@argv);
+        my @k = $lei->url_folder_cache->keys($argv[-1], 1);
+        my @m = map { $match_cb->($_) } @k;
+        my %f = map { $_ => 1 } (@m ? @m : @k);
         if (my $lms = $lei->lms) {
-                @m = map { $match_cb->($_) } $lms->folders;
-                @f{@m} = @m;
+                @k = $lms->folders($argv[-1], 1);
+                @m = map { $match_cb->($_) } @k;
+                if (@m) { @f{@m} = @m } else { @f{@k} = @k }
         }
         keys %f;
 }