#!/bin/bash

# shellcheck source=../scripts/helpers/index.sh
source /usr/local/bin/helpers/index.sh

function _main() {
  _require_n_parameters_or_print_usage 2 "${@}"

  local MAIL_ALIAS="${1}"
  local RECIPIENT="${2}"

  _manage_virtual_aliases_delete "${MAIL_ALIAS}" "${RECIPIENT}"
}

function __usage() {
  printf '%s' "${PURPLE}delalias${RED}(${YELLOW}8${RED})

${ORANGE}USAGE${RESET}
    ./setup.sh alias del <MAIL ALIAS> <RECIPIENT>

${ORANGE}OPTIONS${RESET}
    ${BLUE}Generic Program Information${RESET}
        help       Print the usage information.

${ORANGE}DESCRIPTION${RESET}
    Remove a mail account (the recipient) from an existing alias.
    If the alias has no more recipients, the alias will also be removed.

${ORANGE}EXAMPLES${RESET}
    ${LWHITE}./setup.sh alias del alias@example.com recipient@example.com${RESET}
        Remove the account 'recipient@example.com' from the alias 'alias@example.com'.

${ORANGE}EXIT STATUS${RESET}
    Exit status is 0 if command was successful. If wrong arguments are provided
    or arguments contain errors, the script will exit early with exit status 1.

"
}

_main "${@}"
