Catmandu

 view release on metacpan or  search on metacpan

bin/catmandu  view on Meta::CPAN

use Cwd ();

Catmandu->default_load_path(Cwd::getcwd);
Catmandu::CLI->run // exit(2);

=head1 NAME

catmandu - LibreCat command line tools

=head1 SYNOPSIS

 catmandu [-D|-D2|-D3] [-I path] [-L path] [COMMAND] [-?hqv] [long options...] [ARGS]

 catmandu --version

 catmandu help

 # convert
 catmandu convert JSON to YAML < file.json
 catmandu convert YAML to JSON < file.yaml
 catmandu convert YAML < file.yaml # 'to JSON' is implicit
 catmandu convert MARC < records.mrc
 catmandu convert MARC --fix 'marc_map(245,title)' < records.mrc
 catmandu convert MARC --fix myfixes.txt < records.mrc
 catmandu convert OAI --url https://biblio.ugent.be/oai
 catmandu convert SRU --base http://www.unicat.be/sru --query dna

 # import
 catmandu import JSON to MongoDB --database_name mydb < records.json
 catmandu import MARC to MongoDB --database_name mydb < records.mrc
 catmandu import MARC to ElasticSearch --index_name mydb < records.mrc
 catmandu import MARC to ElasticSearch --index_name mydb --fix 'marc_map("245a","title")' < records.mrc

 # export
 catmandu export MongoDB --database_name mydb --bag data to JSON
 catmandu export MongoDB --database_name mydb --bag data to JSON --fix 'retain("_id")'
 catmandu export Solr --url http://localhost:8983/solr to JSON
 catmandu export ElasticSearch --index_name mydb to JSON

 # copy
 catmandu copy MongoDB --database_name mydb to ElasticSearch --index_name mydb 

 # show the contents of catmandu.yml
 catmandu config   

 # count items in a store
 catmandu count test1

 # delete items from store
 catmandu delete test1 -q 'title:"My Rabbit"'

 # run a fix script
 $ catmandu run myfixes.fix

 # or, create an executable fix script
 $ cat myfixes.fix
 #!/usr/local/bin/catmandu run
 do importer(OAI,url:"http://biblio.ugent.be/oai")
    retain(_id)
 end
 $ chmod 755 myfixes.fix
 $ ./myfixes.fix
 
 # configuration
 $ cat catmandu.yml
 ---
 store:
  test1:
   package: MongoDB
   options:
    database_name: mydb
 catmandu import JSON to test1 < records.json

 # show installed commands
 $ catmandu info
 $ catmandu info --namespace XML

=head1 COMMANDS

=head2 help COMMAND

Documentation about command line options.

=head2 config

Display the contents of the catmandu.yml files in your project.

=head2 convert IMPORTER [OPTIONS] [[--fix FIX]] to EXPORTER [OPTIONS]

Convert data from one format to another format with help of L<Catmandu::Importer>s and
L<Catmandu::Exporter>s. All options given on the command line will be send to the Importer
or Exporter as initialization parameters. E.g.

 catmandu convert OAI --url BASEURL --metadataPrefx PREFIX \
                  to \
                  CSV --header 1 --sep_char '|'

Look at the documentation of all the importers and exporters to see which options are
available.

All importers accept one or more --fix options with the name of a fix file or file command.

 catmandu convert JSON --fix fixes.txt
 catmandu convert JSON --fix 'remove_field(abc)'

The JSON exporter is implicit and is optional.

 catmandu convert YAML to JSON
 catmandu convert YAML # shorter

=head2 copy STORE [OPTIONS] [-q QUERY] [--limit LIMIT] [[--fix FIX]] to STORE [OPTIONS]

Copy items from one L<Catmandu::Store> to another. All options given
on the command line will be send to the Stores as initialization parameters.
Optionally a QUERY and LIMIT can be provided to selectively export items from the Store.
Optionally a FIX can be provided to be executed on all the items before they are
stored.

=head2 count STORE [OPTIONS]

Count the number of items in a L<Catmandu::Store>. All options given on the command line



( run in 1.432 second using v1.01-cache-2.11-cpan-f56aa216473 )