From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 632D41F9E5 for ; Tue, 20 Apr 2021 07:16:55 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] lei edit-search: command to tweak search parameters Date: Tue, 20 Apr 2021 07:16:55 +0000 Message-Id: <20210420071655.22700-3-e@80x24.org> In-Reply-To: <20210420071655.22700-1-e@80x24.org> References: <20210420071655.22700-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 d4055af4..197da2c0 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;