From 4ea40d3f60bdf8e2a8b04f99d8e308309f2748cb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 20 Apr 2021 07:16:55 +0000 Subject: lei edit-search: command to tweak search parameters This may be useful for users to tweak search parameters. This command is also the reason lei.saved-search is a git-config file rather than JSON. --- MANIFEST | 1 + lib/PublicInbox/LEI.pm | 2 ++ lib/PublicInbox/LeiEditSearch.pm | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 lib/PublicInbox/LeiEditSearch.pm diff --git a/MANIFEST b/MANIFEST index 2b73387b..1a1d72a6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -190,6 +190,7 @@ lib/PublicInbox/LeiBlob.pm lib/PublicInbox/LeiConvert.pm lib/PublicInbox/LeiCurl.pm lib/PublicInbox/LeiDedupe.pm +lib/PublicInbox/LeiEditSearch.pm lib/PublicInbox/LeiExternal.pm lib/PublicInbox/LeiForgetSearch.pm lib/PublicInbox/LeiHelp.pm diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index c3c79631..8fa89944 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -162,6 +162,8 @@ our %CMD = ( # sorted in order of importance/use: qw(format|f=s pretty l ascii z|0), @c_opt ], 'forget-search' => [ 'OUTPUT', 'forget a saved search', qw(verbose|v+), @c_opt ], +'edit-search' => [ 'OUTPUT', "edit saved search via `git config --edit'", + @c_opt ], 'plonk' => [ '--threads|--from=IDENT', 'exclude mail matching From: or threads from non-Message-ID searches', diff --git a/lib/PublicInbox/LeiEditSearch.pm b/lib/PublicInbox/LeiEditSearch.pm new file mode 100644 index 00000000..fb36fdcd --- /dev/null +++ b/lib/PublicInbox/LeiEditSearch.pm @@ -0,0 +1,25 @@ +# Copyright (C) 2021 all contributors +# License: AGPL-3.0+ + +# "lei edit-search" edit a saved search following "lei q --save" +package PublicInbox::LeiEditSearch; +use strict; +use v5.10.1; +use PublicInbox::LeiSavedSearch; +use PublicInbox::LeiUp; + +sub lei_edit_search { + my ($lei, $out) = @_; + my $lss = PublicInbox::LeiSavedSearch->up($lei, $out) or return; + my @cmd = (qw(git config --edit -f), $lss->{'-f'}); + $lei->qerr("# spawning @cmd"); + if ($lei->{oneshot}) { + exec(@cmd) or die "exec @cmd: $!\n"; + } else { + $lei->send_exec_cmd([], \@cmd, {}); + } +} + +*_complete_edit_search = \&PublicInbox::LeiUp::_complete_up; + +1; -- cgit v1.2.3-24-ge0c7