from typing import Optional
import click


def _get_delimiter(item: str) -> Optional[str]:
    """
    Returns the delimiter found in the item if any. It may raises an error if delimiter starts or ends
    and item or if there is more than one delimiter in the item.
    :param item: the item to determine delimiters.
    """
    delimiters = (':=', '=')
    for delimiter in delimiters:
        if delimiter in item:
            if item.startswith(delimiter) or item.endswith(delimiter):
                raise click.UsageError(f'{delimiter} must not starts or ends an item like in {item}')
            if item.count(delimiter) > 1:
                raise click.UsageError(f'{item} contains more than one occurrence of {delimiter}')
            return delimiter