def process_tool_directive(directives, option, dispatch, allowed_values, yields_value=False):
    """Process a directive.

    Parameters
    ----------
    option : str
        The name of the option to be processed.
        Will remove this option from `directives` once processed.
    dispatch : function
        The function to call.
    allowed_values : list
        If not None, the value of directives[option] will be checked against this list
    yields_value : boolean, default False
        Tells this function to expect a return from the dispatch function and give it back as needed
    """
    if option in directives:
        value = directives[option]
        # Validate options
        if allowed_values is not None:
            if value not in allowed_values:
                raise ValueError("'{}' must be one of {}".format(option, allowed_values))
        # Dispatch
        output = dispatch(value)
        # Delete the key once we've processed it
        del directives[option]
        if yields_value:
            return output
        return