1 # Copyright all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # "lei rm-watch" command
5 package PublicInbox::LeiRmWatch;
8 use parent qw(PublicInbox::LeiInput);
11 my ($lei, @argv) = @_;
12 my $cfg = $lei->_lei_cfg(1);
13 $lei->{opt}->{'mail-sync'} = 1; # for prepare_inputs
14 my $self = bless { missing_ok => 1 }, __PACKAGE__;
15 $self->prepare_inputs($lei, \@argv) or return;
16 for my $w (@{$self->{inputs}}) {
17 $lei->_config('--remove-section', "watch.$w");
19 delete $lei->{cfg}; # force reload
20 $lei->refresh_watches;
23 sub _complete_rm_watch {
24 my ($lei, @argv) = @_;
25 my $cfg = $lei->_lei_cfg or return;
26 my $match_cb = $lei->complete_url_prepare(\@argv);
27 my @w = (join("\n", keys %$cfg) =~ m/^watch\.(.+?)\.state$/sgm);
28 map { $match_cb->($_) } @w;