# PODNAME: koha-dump-biblio
# ABSTRACT: Dump a Koha Catalog

use Modern::Perl;
use Pod::Usage;
use Getopt::Long;
use Koha::Contrib::Tamil::Biblio::Dumper;

my $verbose  = 0;
my $help     = 0;
my $formater = 'iso2709';
my @branches;
my $query    = '';
    'verbose|v'    => \$verbose,
    'branch|b=s'   => \@branches,
    'query|q=s'    => \$query,
    'formater|f=s' => \$formater,
    'help|h'       => \$help,

sub usage {
    pod2usage( -verbose => 2 );

usage() if $help;          

my $file = $ARGV[0] // 'dump.mrc';

my $dumper = Koha::Contrib::Tamil::Biblio::Dumper->new(
    verbose  => $verbose,
    file     => $file,
    branches => \@branches,
    query    => $query,
    formater => $formater,



=encoding UTF-8

=head1 NAME

koha-dump-biblio - Dump a Koha Catalog

=head1 VERSION

version 0.068


With this script you can export a Koha Catalog in whole or in part. Without
parameter, the whole catalog is exported in an ISO2709 file named dump.mrc.
Playing with parameters, you can:


=item *

Specify the name of the file containing the exported records.

=item *

Specifiy the format of the file: ISO2709 or MARCXML.

=item *

Select the exported biblio records and items, based on branch names, and/or a
SQL query. For example, you can export all the biblio records from a specific
library that have been added the last week, with an item call number beginning
with a specific letter.


=head1 NAME

koha-dump-biblio - Dump a Koha Catalog


 koha-dump-biblio --branch MAIN
 koha-dump-biblio --branch MAIN --branch EAST catalog.mrc
 koha-dump-biblio --branch MAIN --formater marcxml catalog.xml
 koha-dump-biblio --branch MAIN --query "SELECT biblionumber FROM items WHERE barcode LIKE 'X%' --formater marcxml catalog.xml



=item B<-formater=iso2709|marcxml|text|yaml|json>

Specify the format of the file containing the exported records. You can choose
between ISO2709 format and MARCXML, but also textual formts. By default

=item B<-branch>

Select the library of the items to be included to the exported biblio records.
You can select several libraries by repeating this parameter. For example:
B<-branch MAIN -branch EAST>. If the B<-query> parameter isn't used, the
B<-branch> parameter select also the biblio records. In other words, biblio
records without items belonging the the specifed libraries won't be exported.

=item B<-query>

This parameter contains an SQL query which select the biblio records to export
with their biblionumber.

For example:


=item Select two records, biblionumber 10 and 100:

-query "SELECT 10 AS biblionumber UNION ALL SELECT 11 AS biblionumber"

=item Select records containing items which barcode start with a X:

-query "SELECT biblionumber FROM items WHERE barcode LIKE 'X%'"


=item B<--verbose|-v>

Display a progress status of the export process.

=item B<--help|-h>

Print this help page.



Copyright 2013 by Tamil, s.a.r.l.


This library is free software; you can redistribute it and/or modify it under
the same terms as Perl 5 itself.

=head1 AUTHOR

Frédéric Demians <f.demians@tamil.fr>


This software is Copyright (c) 2022 by Fréderic Démians.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007