user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
blob 7a4bbcf80a3af3ab47266c16de8298b0cfb5a4ae 1308 bytes (raw)
name: lib/PublicInbox/LeiForgetExternal.pm 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

# "lei forget-external" command
package PublicInbox::LeiForgetExternal;
use strict;
use v5.10.1;

sub lei_forget_external {
	my ($lei, @locations) = @_;
	my $cfg = $lei->_lei_cfg or
		return $lei->fail('no externals configured');
	my %seen;
	for my $loc (@locations) {
		for my $l ($loc, $lei->ext_canonicalize($loc)) {
			next if $seen{$l}++;
			my $key = "external.$l.boost";
			delete($cfg->{$key});
			$lei->_config('--unset', $key);
			if ($? == 0) {
				$lei->qerr("# $l forgotten ");
			} elsif (($? >> 8) == 5) {
				$lei->err("# $l not found");
			} else {
				$lei->err("# --unset $key error");
				return $lei->x_it($?);
			}
		}
	}
}

# shell completion helper called by lei__complete
sub _complete_forget_external {
	my ($lei, @argv) = @_;
	my $cfg = $lei->_lei_cfg or return ();
	my ($cur, $re, $match_cb) = $lei->complete_url_prepare(\@argv);
	# FIXME: bash completion off "http:" or "https:" when the last
	# character is a colon doesn't work properly even if we're
	# returning "//$HTTP_HOST/$PATH_INFO/", not sure why, could
	# be a bash issue.
	map {
		$match_cb->(substr($_, length('external.')));
	} grep(/\Aexternal\.$re\Q$cur/, @{$cfg->{-section_order}});
}

1;

debug log:

solving 7a4bbcf80a3a ...
found 7a4bbcf80a3a in https://80x24.org/public-inbox.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).