Decodes a line that was captured from the running process using a given encoding (defaults to UTF8)

    Runs that line into the filters, and output the decoded line back if no filter catches it.

    :param line: line to parse
    :type line: str
    :param context: run context
    :type context: RunContext
    :return: optional line
    :rtype: str

def decode_and_filter(line: bytes, context: RunContext) -> typing.Optional[str]:
    """
    Decodes a line that was captured from the running process using a given encoding (defaults to UTF8)

    Runs that line into the filters, and output the decoded line back if no filter catches it.

    :param line: line to parse
    :type line: str
    :param context: run context
    :type context: RunContext
    :return: optional line
    :rtype: str
    """
    line_str: str = line.decode(context.console_encoding, errors='replace')
    filtered_line: typing.Optional[str] = filter_line(line_str, context)
    if filtered_line:
        return filtered_line.rstrip()

    return None