unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/2] "lei up" improvements
@ 2021-08-12 23:40 Eric Wong
  2021-08-12 23:40 ` [PATCH 1/2] lei up: support multiple output folders w/o --all=local Eric Wong
  2021-08-12 23:40 ` [PATCH 2/2] lei up: note errors if one output destination fails Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-12 23:40 UTC (permalink / raw)
  To: meta

Some obvious things for now, some maybe not-so-obvious things on
the way...

Eric Wong (2):
  lei up: support multiple output folders w/o --all=local
  lei up: note errors if one output destination fails

 lib/PublicInbox/LEI.pm   |  2 +-
 lib/PublicInbox/LeiUp.pm | 23 +++++++++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] lei up: support multiple output folders w/o --all=local
  2021-08-12 23:40 [PATCH 0/2] "lei up" improvements Eric Wong
@ 2021-08-12 23:40 ` Eric Wong
  2021-08-12 23:40 ` [PATCH 2/2] lei up: note errors if one output destination fails Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-12 23:40 UTC (permalink / raw)
  To: meta

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(<<EOM);
+multiple outputs and --mua= are incompatible
+EOM
+		# TODO:
+		return $lei->fail(<<EOM) if grep(m!\Aimaps?://!i, @outs);
+multiple destinations only supported for local outputs (FIXME)
+EOM
+	}
+	if (scalar(@local) > 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]);
 	}
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] lei up: note errors if one output destination fails
  2021-08-12 23:40 [PATCH 0/2] "lei up" improvements Eric Wong
  2021-08-12 23:40 ` [PATCH 1/2] lei up: support multiple output folders w/o --all=local Eric Wong
@ 2021-08-12 23:40 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-12 23:40 UTC (permalink / raw)
  To: meta

We can keep going if one (out of multiple) output destinations
fail, but the error needs to be communicated to the caller as an
exit code.
---
 lib/PublicInbox/LeiUp.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index 49b558fd..c5a01527 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -57,7 +57,7 @@ sub up1_redispatch {
 		up1($l, $out);
 		$l->qerr("# $out done");
 	};
-	$l->err($@) if $@;
+	$l->child_error(1 << 8, $@) if $@;
 }
 
 sub lei_up {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-12 23:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 23:40 [PATCH 0/2] "lei up" improvements Eric Wong
2021-08-12 23:40 ` [PATCH 1/2] lei up: support multiple output folders w/o --all=local Eric Wong
2021-08-12 23:40 ` [PATCH 2/2] lei up: note errors if one output destination fails Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).