public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 19bee3ab6f048f8f88bc6ec574f5f8a518d96721 866 bytes (raw)
$ git show HEAD:lib/PublicInbox/LeiRmWatch.pm	# shows this blob on the CLI

 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
 
# Copyright all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

# "lei rm-watch" command
package PublicInbox::LeiRmWatch;
use strict;
use v5.10.1;
use parent qw(PublicInbox::LeiInput);

sub lei_rm_watch {
	my ($lei, @argv) = @_;
	my $cfg = $lei->_lei_cfg(1);
	$lei->{opt}->{'mail-sync'} = 1; # for prepare_inputs
	my $self = bless { missing_ok => 1 }, __PACKAGE__;
	$self->prepare_inputs($lei, \@argv) or return;
	for my $w (@{$self->{inputs}}) {
		$lei->_config('--remove-section', "watch.$w") or return;
	}
	delete $lei->{cfg}; # force reload
	$lei->refresh_watches;
}

sub _complete_rm_watch {
	my ($lei, @argv) = @_;
	my $cfg = $lei->_lei_cfg or return;
	my $match_cb = $lei->complete_url_prepare(\@argv);
	my @w = (join("\n", keys %$cfg) =~ m/^watch\.(.+?)\.state$/sgm);
	map { $match_cb->($_) } @w;
}

1;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git