#! /usr/bin/env perl
# vim: set filetype=perl ts=4 sw=4 sts=4 et:
use common::sense;

use File::Basename;
use lib dirname(__FILE__) . '/../../../lib/perl';
use OVH::Result;
use OVH::Bastion;
use OVH::Bastion::Plugin qw( :DEFAULT help );
use OVH::Bastion::Plugin::groupSetRole;

my ($account, $group);
my $remainingOptions = OVH::Bastion::Plugin::begin(
    argv     => \@ARGV,
    header   => "revoke an account as owner of a group",
    options  => {"account=s", \$account, "group=s", \$group},
    helptext => <<'EOF',
Remove the group owner role from an account

Usage: --osh SCRIPT_NAME --group GROUP --account ACCOUNT

  --group GROUP      which group to set ACCOUNT as an owner of
  --account ACCOUNT  which account to set as an owner of GROUP

The specified account will no longer be able to manage the owner,
gatekeeper and aclkeeper lists of this group
EOF
);

my $fnret = OVH::Bastion::Plugin::groupSetRole::act(
    account        => $account,
    group          => $group,
    action         => 'del',
    type           => 'owner',
    sudo           => 0,
    silentoverride => 0,
    self           => $self,
    scriptName     => $scriptName,
    savedArgs      => $savedArgs
);
help() if not $fnret;
osh_exit($fnret);
