from typing import Dict
from typing import Any


def add_parser_options(options: Dict[str, Dict[str, Any]], parser_id: str, parser_options: Dict[str, Dict[str, Any]],
                       overwrite: bool = False):
    """
    Utility method to add options for a given parser, to the provided options structure
    :param options:
    :param parser_id:
    :param parser_options:
    :param overwrite: True to silently overwrite. Otherwise an error will be thrown
    :return:
    """
    if parser_id in options.keys() and not overwrite:
        raise ValueError('There are already options in this dictionary for parser id ' + parser_id)
    options[parser_id] = parser_options
    return options