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 4E70E1F8C7 for ; Thu, 12 Aug 2021 23:40:28 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] lei up: support multiple output folders w/o --all=local Date: Thu, 12 Aug 2021 23:40:26 +0000 Message-Id: <20210812234027.5456-2-e@80x24.org> In-Reply-To: <20210812234027.5456-1-e@80x24.org> References: <20210812234027.5456-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Being able to update 1 folder, or all (local) folders is sometimes too limiting, so just allow updating any subset of local folders. --- lib/PublicInbox/LEI.pm | 2 +- lib/PublicInbox/LeiUp.pm | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 54fac7b4..7d0f63dc 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -178,7 +178,7 @@ our %CMD = ( # sorted in order of importance/use: import-before! lock=s@ rsyncable alert=s@ mua=s verbose|v+ shared color! mail-sync!), @c_opt, opt_dash('limit|n=i', '[0-9]+') ], -'up' => [ 'OUTPUT|--all', 'update saved search', +'up' => [ 'OUTPUT...|--all', 'update saved search', qw(jobs|j=s lock=s@ alert=s@ mua=s verbose|v+ all:s), @c_opt ], 'lcat' => [ '--stdin|MSGID_OR_URL...', 'display local copy of message(s)', diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm index 3356d11e..49b558fd 100644 --- a/lib/PublicInbox/LeiUp.pm +++ b/lib/PublicInbox/LeiUp.pm @@ -61,11 +61,13 @@ sub up1_redispatch { } sub lei_up { - my ($lei, $out) = @_; + my ($lei, @outs) = @_; $lei->{lse} = $lei->_lei_store(1)->search; my $opt = $lei->{opt}; $opt->{save} = -1; + my @local; if (defined $opt->{all}) { + return $lei->fail("--all and @outs incompatible") if @outs; length($opt->{mua}//'') and return $lei->fail('--all and --mua= are incompatible'); @@ -74,7 +76,20 @@ sub lei_up { $opt->{all} eq 'local' or return $lei->fail('only --all=local works at the moment'); my @all = PublicInbox::LeiSavedSearch::list($lei); - my @local = grep(!m!\Aimaps?://!i, @all); + @local = grep(!m!\Aimaps?://!i, @all); + } else { + @local = @outs; + } + if (scalar(@outs) > 1) { + length($opt->{mua}//'') and return $lei->fail(<fail(< 1) { $lei->_lei_store->write_prepare($lei); # share early # daemon mode, re-dispatch into our event loop w/o # creating an extra fork-level @@ -89,7 +104,7 @@ sub lei_up { $lei->event_step_init; $op_c->{ops} = { '' => [$lei->can('dclose'), $lei] }; } else { - up1($lei, $out); + up1($lei, $local[0]); } }