]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/LeiForgetSearch.pm
ds: inline set_cloexec
[public-inbox.git] / lib / PublicInbox / LeiForgetSearch.pm
1 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # "lei forget-search" forget/remove a saved search "lei q --save"
5 package PublicInbox::LeiForgetSearch;
6 use strict;
7 use v5.10.1;
8 use PublicInbox::LeiSavedSearch;
9 use PublicInbox::LeiUp;
10 use File::Path ();
11 use SelectSaver;
12
13 sub lei_forget_search {
14         my ($lei, $out) = @_;
15         my $d = PublicInbox::LeiSavedSearch::lss_dir_for($lei, \$out);
16         if (-e $d) {
17                 my $save;
18                 my $opt = { safe => 1 };
19                 if ($lei->{opt}->{verbose}) {
20                         $opt->{verbose} = 1;
21                         $save = SelectSaver->new($lei->{2});
22                 }
23                 File::Path::remove_tree($d, $opt);
24         } else {
25                 $lei->fail("--save was not used with $out cwd=".
26                                         $lei->rel2abs('.'));
27         }
28 }
29
30 *_complete_forget_search = \&PublicInbox::LeiUp::_complete_up;
31
32 1;