#!/usr/bin/env bash
# commands/group/rule.sh

function cmd::group::rule::on_load() {
  flag::define --name   value "Group name" required label:name
  flag::define --rule   value "Rule name"  required label:rule
  flag::define --action value "Action"     required choices:assign,unassign label:action
}

function cmd::group::rule::run() {
  flag::parse "$@" || return 1
  local name;   name=$(flag::value --name)
  local rule;   rule=$(flag::value --rule)
  local action; action=$(flag::value --action)
  case "$action" in
    assign)   cmd::group::_rule_assign_impl   "$name" "$rule" ;;
    unassign) cmd::group::_rule_unassign_impl "$name" "$rule" ;;
  esac
}
