#!/miniconda/bin/python3

from meerkat_abacus import tasks
from meerkat_abacus.config import config
import yaml
import argparse

# Setup the argument parsing.
parser = argparse.ArgumentParser(
    "send_email",
    description="Trigger the email sending process for debugging."
)
parser.add_argument(
    'report',
    type=str,
    help='The id of the report email to send.'
)
parser.add_argument(
    '--lang',
    metavar='en',
    type=str,
    default='en',
    help='The langauge the report should be sent in.'
)
parser.add_argument(
    '--loc',
    metavar='1',
    type=int,
    default=1,
    help='The id of the location the report should be sent for.'
)
args = parser.parse_args()
args_dict = vars(args)

# Check the cerf report region because unlike other reports it isn't sent for 1
if args_dict['report'] == 'cerf' and args_dict['loc'] != 19:
    args_dict['loc'] = int(input(
        'NOTE: CERF should be sent for Androy '
        'region 19. Please confirm location ID: '
    ))

print(args_dict)

tasks.send_report_email(
    args_dict['report'], args_dict['lang'],
    args_dict['loc'],
    yaml.dump(config)
)
