From 9bb973c8c79275f02c08ef26b6acec345c086c64 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 20 Aug 2021 10:14:16 -0400 Subject: [PATCH] LP1940662: Add a --pipe option to marc_export Add a --pipe option to marc_export to force reading of record ids from standard input when one or more of the --since, --library, or --descendants options are used. This permits more flexibility when exporting records with holdings for given libraries or subsets of a collection. It is an error to specify the --all and --pipe options in the same command line. Signed-off-by: Jason Stephenson --- Open-ILS/src/support-scripts/marc_export.in | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index 843ddff1ca..0b4c361bd2 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -99,7 +99,8 @@ sub new { 'since=s', 'store=s', 'uris', - 'debug'); + 'debug', + 'pipe'); if ($opts{help}) { print <<"HELP"; @@ -129,6 +130,8 @@ Usage: $0 [options] --store Use the given storage backend to connect to the database. Choices are (reporter, cstore, storage) [reporter] --since Export records modified since a certain date and time. + --pipe Force record ids to be read from list on standard input, + despite other options to the contrary Additional options for type = 'BIBLIO': --items or -i Include items (holdings) in the output @@ -181,6 +184,10 @@ HELP die('Incompatible arguments: you cannot combine a request for all ' . 'records with a request for records added or changed since a certain date'); } + if ($opts{all} && $opts{pipe}) { + die('Incompatible arguments: you cannot combine a request for all ' . + 'records with the option to read record ids via standard input'); + } $opts{type} = lc($opts{type}); if (none {$_ eq $opts{type}} (TYPES)) { die "Please select a supported type. ". @@ -253,10 +260,13 @@ sub need_ids { my $self = shift; my $rv = 1; - $rv = 0 if ($self->{options}->{all}); $rv = 0 if ($self->{options}->{since}); $rv = 0 if ($self->{options}->{library}); $rv = 0 if ($self->{options}->{descendants}); + # --pipe trumps the above. + $rv = 1 if ($self->{options}->{pipe}); + # --all trumps --pipe, but we should throw an error before we get here. + $rv = 0 if ($self->{options}->{all}); return $rv; } -- 2.11.0