#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Perun::Agent;
use Perun::Common qw(printMessage);

sub help {
	return qq{
	Adds next owner to specific User. User id and owner id is required.
	--------------------------------------
	Available options:
	--userId       | -u user id
	--owner        | -o owner Id
	--batch        | -b batch
	--help         | -h prints this help

	};
}

my ($userId, $ownerId, $batch);
GetOptions ("help|h"  => sub {
		print help();
		exit 0;
	}, "batch|b"        => \$batch,
	"userId|u=i"        => \$userId, 
	"owner|o=i"         => \$ownerId) || die help();

# Check options
unless (defined($userId)) { die "ERROR: userId is required \n";}
unless (defined($ownerId)) { die "ERROR: ownerId is required \n";}

my $agent = Perun::Agent->new();
my $usersAgent = $agent->getUsersAgent;

$usersAgent->addSpecificUserOwner( specificUser => $userId, user => $ownerId );

printMessage("Next owner $ownerId added to Specific user $userId successfully.", $batch);
