#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

# PODNAME: qbit_tanker_download

=encoding UTF-8
=cut

=head1 SYNOPSIS

qbit_tanker_download

 No obligatory options. All the settings are taken from config file
 `qbit_tanker.conf`.

 Optional options:
      --tanker_branch=the_master    Tanker branch name to download translation. The default branch is master

Script will download translations from tanker for the QBit project.

=cut

use strict;
use warnings FATAL => 'all';
use Carp;

use QBit::Tanker;
use Getopt::Long;
use Pod::Usage;

sub main {

    my $qt_ref = QBit::Tanker->new();

    my $tanker_branch;
    GetOptions(
        'help|h' => sub { pod2usage({-message => ''}); exit; },
        "tanker_branch=s" => \$tanker_branch,
    )
    or croak "Error in command line arguments\n";

    $tanker_branch = $tanker_branch // 'master';

    $qt_ref->__download_all_po_from_tanker( $tanker_branch );
    $qt_ref->__extract_strings_to_po();
    $qt_ref->__merge_po;

    foreach my $lang ( $qt_ref->__get_langs() ) {
        $qt_ref->__compile_mo($lang);
        $qt_ref->__create_js($lang);
    }

    $qt_ref->__rm_tmp_files();

}

main();
__END__
