#!/usr/bin/perl

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

# PODNAME: qbit_tanker_merge

=encoding UTF-8
=cut

=head1 SYNOPSIS

qbit_tanker_merge

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

 Optional options:

      --source=feature_x      Source branch name. Default value is master.
      --dest=master           Destination branch name. By default is queried from terminal.

Script will merge translations from one tanker branch to another one.

=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 $source_branch_name;
    my $dest_branch_name;
    GetOptions(
        'help|h' => sub { pod2usage({-message => ''}); exit; },
        "source=s" => \$source_branch_name,
        "dest=s" => \$dest_branch_name,
    )
    or croak "Error in command line arguments\n";

    $source_branch_name ||= 'master';
    $dest_branch_name = $qt_ref->__get_tanker_branch_to_merge_to($source_branch_name, $dest_branch_name);

    $qt_ref->__merge_in_tanker(
        from => $source_branch_name,
        to => $dest_branch_name,
    );

    $qt_ref->__delete_tanker_branch_if_needed( $source_branch_name );

}

main();
__END__
