#!/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{
	Deletes an attribute. Attribute id is required.
	--------------------------------------
	Available options:
	--attributeId  | -a attribute id
	--force        | -f delete also all dependent data
	--batch        | -b batch
	--help         | -h prints this help

	};
}

my ($attributeId, $batch, $force);
GetOptions ("help|h"  => sub {
		print help();
		exit 0;
	}, "batch|b"      => \$batch,
	"attributeId|a=i" => \$attributeId,
	"force|f"         => \$force) || die help();

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

my $agent = Perun::Agent->new();
my $attributesAgent = $agent->getAttributesAgent;

if (defined($force)) {
	$attributesAgent->deleteAttribute( attribute => $attributeId, force => 1 );
} else {
	$attributesAgent->deleteAttribute( attribute => $attributeId )
}

printMessage("Attribute Id:$attributeId successfully deleted", $batch);
