import click


def validate_entry_id(ctx, param, value):
    """
    Validate that entry ID is either a integer or a string for a valid 
    keyword (currently only 'last')
    
    Return either an integer or a string. Raise a click exception if value 
    is not an integer or a valid keyword.
    """
    try:
        value = int(value)
        return value
    except ValueError:
        if value != 'last':
            raise click.BadParameter('value must be a valid integer or at least the keyword "last" (that means the last entry)')
        else:
            return value