# Wrapper of the command line
sub taktuk{
    # Gets the parameters of the subroutine invocation
    my ($out,$machines,$files) = @_;
    my $count = 0;
    my $mach_cmd;
    my $cmd = "";
    #Taktuk string for file colection
    my $tkfiles = "";
    
    #Dereferences machines
    my @machines = @$machines;
    # list of taktuk machines
    my $tkmachines = join(" -m ",@machines);
    
    if ($files == 1){
        $cmd = "broadcast put [ 'packs/deploy.tar.gz' ] [ 'deploy.tar.gz' ]";
        system("./taktuk-3.6.1/taktuk $out -s $tkfiles -m $tkmachines $cmd");
        $cmd = "broadcast put [ 'packs/deps.tar.gz' ] [ 'deps.tar.gz' ]";
        system("./taktuk-3.6.1/taktuk $out -s $tkfiles -m $tkmachines $cmd");
        $cmd = "broadcast exec [ 'mkdir /tmp/log' ]";
        system("./taktuk-3.6.1/taktuk $out -s $tkfiles -m $tkmachines $cmd");
        return;
    }elsif($files == 2){
        $cmd = "broadcast put [ 'packs/deps.tar.gz' ] [ 'deps.tar.gz' ]";
        system("./taktuk-3.6.1/taktuk $out -s $tkfiles -m $tkmachines $cmd");
        $cmd = "broadcast exec [ 'mkdir /tmp/log' ]";
        system("./taktuk-3.6.1/taktuk $out -s $tkfiles -m $tkmachines $cmd");

    }else {
        for my $mach (@machines){
            $count += 1;
            $mach_cmd = lookup($mach,"command");
            $cmd = $cmd." $count exec [ ' $mach_cmd ' ], ";
        }
    }
    # Runs taktuk and return the exit status
    return system("./taktuk-3.6.1/taktuk  $out -s $tkfiles -m $tkmachines $cmd");
}

1;
