import difflib


def diff_output(expected: str, actual: str) -> str:
    """
    Compares the expected and actual outputs of a command

    Args:
        expected: desired output
        actual: STDOUT captured from command

    Returns:
        str: diff output
    """

    # files read in are converted to "universal" newlines so convert captured output too
    actual = actual.replace("\r\n", "\n")
    return "".join(
        difflib.unified_diff(
            expected.splitlines(keepends=True),
            actual.splitlines(keepends=True),
            fromfile="expected",
            tofile="actual",
        )
    )