import re


def transform_version_rule(rule: str) -> str:
    """Transform a giza-style version rule to a mut-style version rule."""
    if rule == 'all':
        return '[*]'

    match = re.match(r'((?:after)|(?:before)|)-?(.*)', rule)
    assert match
    if match.group(1) == 'after':
        return '({}-*]'.format(match.group(2))
    elif match.group(2) == 'before':
        return '(*-{}]'.format(match.group(2))

    return '[{}]'.format(match.group(2))