1 # Copyright (C) all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # "lei forget-external" command
5 package PublicInbox::LeiForgetExternal;
9 sub lei_forget_external {
10 my ($lei, @locations) = @_;
11 my $cfg = $lei->_lei_cfg or
12 return $lei->fail('no externals configured');
14 for my $loc (@locations) {
15 for my $l ($loc, $lei->ext_canonicalize($loc)) {
17 my $key = "external.$l.boost";
19 $lei->_config('--unset', $key);
21 $lei->qerr("# $l forgotten ");
22 } elsif (($? >> 8) == 5) {
23 warn("# $l not found\n");
25 $lei->child_error($?, "# --unset $key error");
31 # shell completion helper called by lei__complete
32 sub _complete_forget_external {
33 my ($lei, @argv) = @_;
34 my $cfg = $lei->_lei_cfg or return ();
35 my ($cur, $re, $match_cb) = $lei->complete_url_prepare(\@argv);
36 # FIXME: bash completion off "http:" or "https:" when the last
37 # character is a colon doesn't work properly even if we're
38 # returning "//$HTTP_HOST/$PATH_INFO/", not sure why, could
41 $match_cb->(substr($_, length('external.')));
42 } grep(/\Aexternal\.$re\Q$cur/, @{$cfg->{-section_order}});