import click


def parse_version_str(version_str):
    """
    Parse a string with 3 positive integers seperated by period (CIM version
    string) into a 3 integer tuple and return the tuple. Used to parse the
    version value of the DMTF Version qualifier.

    Parameters:
        version_str (:term: str):
            String defining 3 components of a CIM version

    Returns:
        tuple containing 3 integers

    Raises:
        click.ClickException if the version_str is invalid (not integers,
        not seperated by ".", not 3 values)
    """
    try:
        version_tuple = [int(x) for x in version_str.split('.')]
    except ValueError:
        raise click.ClickException('--since option value invalid. '
                                   'Must contain 3 integer elements: '
                                   'int.int.int". {} received'.
                                   format(version_str))
    if len(version_tuple) != 3:
        raise click.ClickException('Version value must contain 3 integer '
                                   'elements (int.int.int). '
                                   '{} received'.format(version_str))
    return version_tuple