from typing import List


def format_tags(tags: str, arg = "--tag") -> List[str]:
    """
    Takes a comma separated list of tags.
    Splits them and appends --tag to each tag.
    Use the output as the command line argument for the restic cli.
    Example: foo,bar,test becomes --tag foo --tag bar --tag test
    """
    if not tags:
        return []

    tags = tags.strip()
    splitTags = tags.split(",")
    output = []
    for tag in splitTags:
        tag = tag.strip()
        if tag:
            output.extend([arg, tag])
                
    return output